Changeset bc73be3 in mainline for uspace/app


Ignore:
Timestamp:
2019-06-27T08:51:20Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8add15e0
Parents:
ad40b74b (diff), aeba767 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

cpp: merge and resolve conflicts

Location:
uspace/app
Files:
17 added
12 deleted
28 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/barber/barber.c

    rad40b74b rbc73be3  
    4545#include <window.h>
    4646#include <canvas.h>
    47 #include <surface.h>
    48 #include <codec/tga.gz.h>
     47#include <draw/surface.h>
     48#include <draw/codec.h>
    4949#include "images.h"
    5050
  • uspace/app/bdsh/Makefile

    rad40b74b rbc73be3  
    3434
    3535SOURCES = \
     36        cmds/modules/module_aliases.c \
     37        cmds/modules/modules.c \
    3638        cmds/modules/help/help.c \
    3739        cmds/modules/mkdir/mkdir.c \
     
    5153        cmds/modules/kcon/kcon.c \
    5254        cmds/modules/cmp/cmp.c \
     55        cmds/builtins/builtin_aliases.c \
     56        cmds/builtins/builtins.c \
    5357        cmds/builtins/batch/batch.c \
    5458        cmds/builtins/exit/exit.c \
  • uspace/app/bdsh/cmds/builtins/builtin_aliases.h

    rad40b74b rbc73be3  
     1/*
     2 * Copyright (c) 2008 Tim Post
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
    129#ifndef BUILTIN_ALIASES_H
    230#define BUILTIN_ALIASES_H
    331
    4 /* See modules/module_aliases.h for an explanation of this file */
    5 
    6 char *builtin_aliases[] = {
    7         NULL, NULL
    8 };
     32extern char *builtin_aliases[];
    933
    1034#endif
  • uspace/app/bdsh/cmds/builtins/builtins.h

    rad40b74b rbc73be3  
     1/*
     2 * Copyright (c) 2008 Tim Post
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
    129#ifndef BUILTINS_H
    230#define BUILTINS_H
    331
    4 #include "config.h"
     32#include "../cmds.h"
    533
    6 #include "batch/entry.h"
    7 #include "cd/entry.h"
    8 #include "exit/entry.h"
    9 
    10 builtin_t builtins[] = {
    11 #include "batch/batch_def.inc"
    12 #include "cd/cd_def.inc"
    13 #include "exit/exit_def.inc"
    14         { NULL, NULL, NULL, NULL, 0 }
    15 };
     34extern builtin_t builtins[];
    1635
    1736#endif
  • uspace/app/bdsh/cmds/mknewcmd

    rad40b74b rbc73be3  
    213213        printf " to include your new command.\n"
    214214        [ -n "$CMDALIAS" ] &&  {
    215                 printf "\nYou should also modify %ss/%s_aliases.h and " \
     215                printf "\nYou should also modify %ss/%s_aliases.c and " \
    216216                        "${CMDTYPE}" "${CMDTYPE}"
    217217                printf "add %s as an alias for %s\n" \
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    rad40b74b rbc73be3  
    4242#include <vfs/vfs.h>
    4343#include <str.h>
     44#include <cap.h>
    4445
    4546#include "ls.h"
     
    5859        { "unsort", no_argument, 0, 'u' },
    5960        { "recursive", no_argument, 0, 'r' },
     61        { "exact-size", no_argument, 0, 'e' },
     62        { "single-column", no_argument, 0, '1' },
    6063        { 0, 0, 0, 0 }
    6164};
     
    6366/* Prototypes for the ls command, excluding entry points. */
    6467static unsigned int ls_start(ls_job_t *);
    65 static void ls_print(struct dir_elem_t *);
    66 static int ls_cmp(const void *, const void *);
     68static errno_t ls_print(struct dir_elem_t *);
     69static errno_t ls_print_single_column(struct dir_elem_t *);
     70static int ls_cmp_type_name(const void *, const void *);
     71static int ls_cmp_name(const void *, const void *);
    6772static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **);
    6873static unsigned int ls_recursive(const char *, DIR *);
     
    7479        ls->sort = 1;
    7580
     81        ls->exact_size = false;
     82        ls->single_column = false;
     83        ls->printer = ls_print;
    7684        return 1;
    7785}
     
    8896 * @param de            Directory element.
    8997 */
    90 static void ls_print(struct dir_elem_t *de)
    91 {
    92         if (de->s.is_file)
    93                 printf("%-40s\t%llu\n", de->name, (long long) de->s.size);
    94         else if (de->s.is_directory)
    95                 printf("%-40s\t<dir>\n", de->name);
     98static errno_t ls_print(struct dir_elem_t *de)
     99{
     100        int width = 13;
     101
     102        if (de->s.is_file) {
     103                if (ls.exact_size) {
     104                        printf("%-40s\t%*llu\n", de->name, width, (long long) de->s.size);
     105                        return EOK;
     106                }
     107
     108                cap_spec_t cap;
     109                cap_from_blocks(de->s.size, 1, &cap);
     110                cap_simplify(&cap);
     111
     112                char *rptr;
     113                errno_t rc = cap_format(&cap, &rptr);
     114                if (rc != EOK) {
     115                        return rc;
     116                }
     117
     118                char *sep = str_rchr(rptr, ' ');
     119                if (sep == NULL) {
     120                        free(rptr);
     121                        return ENOENT;
     122                }
     123
     124                *sep = '\0';
     125
     126                printf("%-40s\t%*s %2s\n", de->name, width - 3, rptr, sep + 1);
     127                free(rptr);
     128        } else if (de->s.is_directory)
     129                printf("%-40s\t%*s\n", de->name, width, "<dir>");
    96130        else
    97131                printf("%-40s\n", de->name);
     132
     133        return EOK;
     134}
     135
     136static errno_t ls_print_single_column(struct dir_elem_t *de)
     137{
     138        if (de->s.is_file) {
     139                printf("%s\n", de->name);
     140        } else {
     141                printf("%s/\n", de->name);
     142        }
     143
     144        return EOK;
    98145}
    99146
     
    109156 * @return              -1 if a < b, 1 otherwise.
    110157 */
    111 static int ls_cmp(const void *a, const void *b)
     158static int ls_cmp_type_name(const void *a, const void *b)
    112159{
    113160        struct dir_elem_t const *da = a;
     
    120167        else
    121168                return 1;
     169}
     170
     171/** Compare directories/files per name
     172 *
     173 * This comparision ignores the type of
     174 * the node. Sorted will strictly by name.
     175 *
     176 */
     177static int ls_cmp_name(const void *a, const void *b)
     178{
     179        struct dir_elem_t const *da = a;
     180        struct dir_elem_t const *db = b;
     181
     182        return str_cmp(da->name, db->name);
    122183}
    123184
     
    192253        }
    193254
    194         if (ls.sort)
    195                 qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp);
    196 
    197         for (i = 0; i < nbdirs; i++)
    198                 ls_print(&tosort[i]);
     255        if (ls.sort) {
     256                int (*compar)(const void *, const void *);
     257                compar = ls.single_column ? ls_cmp_name : ls_cmp_type_name;
     258                qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), compar);
     259        }
     260
     261        for (i = 0; i < nbdirs; i++) {
     262                if (ls.printer(&tosort[i]) != EOK) {
     263                        cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
     264                        goto out;
     265                }
     266        }
    199267
    200268        /* Populate the directory list. */
     
    333401                    "If not path is given, the current working directory is used.\n"
    334402                    "Options:\n"
    335                     "  -h, --help       A short option summary\n"
    336                     "  -u, --unsort     Do not sort directory entries\n"
    337                     "  -r, --recursive  List subdirectories recursively\n",
     403                    "  -h, --help            A short option summary\n"
     404                    "  -u, --unsort          Do not sort directory entries\n"
     405                    "  -r, --recursive       List subdirectories recursively\n"
     406                    "  -e, --exact-size      File sizes will be unformatted (raw bytes count)\n"
     407                    "  -1, --single-column   Only the names will be returned\n",
    338408                    cmdname);
    339409        }
     
    364434
    365435        while (c != -1) {
    366                 c = getopt_long(argc, argv, "hur", long_options, &opt_ind);
     436                c = getopt_long(argc, argv, "hure1", long_options, &opt_ind);
    367437                switch (c) {
    368438                case 'h':
     
    375445                        ls.recursive = 1;
    376446                        break;
     447                case 'e':
     448                        ls.exact_size = true;
     449                        break;
     450                case '1':
     451                        ls.single_column = true;
     452                        ls.printer = ls_print_single_column;
     453                        break;
    377454                }
    378455        }
     
    400477        switch (scope) {
    401478        case LS_FILE:
    402                 ls_print(&de);
     479                if (ls.printer(&de) != EOK) {
     480                        cli_error(CL_ENOMEM, "%s: Out of memory", cmdname);
     481                        return CMD_FAILURE;
     482                }
    403483                break;
    404484        case LS_DIR:
  • uspace/app/bdsh/cmds/modules/ls/ls.h

    rad40b74b rbc73be3  
    88#define LS_FILE  1
    99#define LS_DIR   2
    10 
    11 typedef struct {
    12         /* Options set at runtime. */
    13         unsigned int recursive;
    14         unsigned int sort;
    15 
    16 } ls_job_t;
    1710
    1811/** Structure to represent a directory entry.
     
    2619};
    2720
     21typedef struct {
     22        /* Options set at runtime. */
     23        unsigned int recursive;
     24        unsigned int sort;
     25
     26        bool single_column;
     27        bool exact_size;
     28
     29        errno_t (*printer)(struct dir_elem_t *);
     30} ls_job_t;
     31
    2832#endif
  • uspace/app/bdsh/cmds/modules/module_aliases.h

    rad40b74b rbc73be3  
    3030#define MODULE_ALIASES_H
    3131
    32 /*
    33  * Modules that declare multiple names for themselves but use the
    34  * same entry functions are aliases. This array helps to determine if
    35  * a module is an alias, as such it can be invoked differently.
    36  * format is alias , real_name
    37  */
    38 
    39 /*
    40  * So far, this is only used in the help display but could be used to
    41  * handle a module differently even prior to reaching its entry code.
    42  * For instance, 'exit' could behave differently than 'quit', prior to
    43  * the entry point being reached.
    44  */
    45 
    46 const char *mod_aliases[] = {
    47         "ren", "mv",
    48         "umount", "unmount",
    49         NULL, NULL
    50 };
     32extern const char *mod_aliases[];
    5133
    5234#endif
  • uspace/app/bdsh/cmds/modules/modules.h

    rad40b74b rbc73be3  
    3030#define MODULES_H
    3131
    32 /*
    33  * Each built in function has two files, one being an entry.h file which
    34  * prototypes the run/help entry functions, the other being a .def file
    35  * which fills the modules[] array according to the cmd_t structure
    36  * defined in cmds.h.
    37  *
    38  * To add or remove a module, just make a new directory in cmds/modules
    39  * for it and copy the 'show' example for basics, then include it here.
    40  * (or reverse the process to remove one)
    41  *
    42  * NOTE: See module_ aliases.h as well, this is where aliases (commands that
    43  * share an entry point with others) are indexed
    44  */
     32#include "../cmds.h"
     33#include "modules.h"
    4534
    46 #include "config.h"
    47 
    48 /* Prototypes for each module's entry (help/exec) points */
    49 
    50 #include "help/entry.h"
    51 #include "mkdir/entry.h"
    52 #include "mkfile/entry.h"
    53 #include "rm/entry.h"
    54 #include "cat/entry.h"
    55 #include "touch/entry.h"
    56 #include "ls/entry.h"
    57 #include "pwd/entry.h"
    58 #include "sleep/entry.h"
    59 #include "cp/entry.h"
    60 #include "mv/entry.h"
    61 #include "mount/entry.h"
    62 #include "unmount/entry.h"
    63 #include "kcon/entry.h"
    64 #include "printf/entry.h"
    65 #include "echo/entry.h"
    66 #include "cmp/entry.h"
    67 
    68 /*
    69  * Each .def function fills the module_t struct with the individual name, entry
    70  * point, help entry point, etc. You can use config.h to control what modules
    71  * are loaded based on what libraries exist on the system.
    72  */
    73 
    74 module_t modules[] = {
    75 #include "help/help_def.inc"
    76 #include "mkdir/mkdir_def.inc"
    77 #include "mkfile/mkfile_def.inc"
    78 #include "rm/rm_def.inc"
    79 #include "cat/cat_def.inc"
    80 #include "touch/touch_def.inc"
    81 #include "ls/ls_def.inc"
    82 #include "pwd/pwd_def.inc"
    83 #include "sleep/sleep_def.inc"
    84 #include "cp/cp_def.inc"
    85 #include "mv/mv_def.inc"
    86 #include "mount/mount_def.inc"
    87 #include "unmount/unmount_def.inc"
    88 #include "kcon/kcon_def.inc"
    89 #include "printf/printf_def.inc"
    90 #include "echo/echo_def.inc"
    91 #include "cmp/cmp_def.inc"
    92 
    93         { NULL, NULL, NULL, NULL }
    94 };
     35extern module_t modules[];
    9536
    9637#endif
  • uspace/app/bdsh/compl.c

    rad40b74b rbc73be3  
    4040#include "exec.h"
    4141#include "tok.h"
     42#include "util.h"
    4243
    4344static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state);
     
    209210                }
    210211                *cstart += rpath_sep + 1 - prefix;
    211                 free(prefix);
    212                 prefix = NULL;
    213212
    214213                cs->path_list = malloc(sizeof(char *) * 2);
     
    217216                        goto error;
    218217                }
    219                 cs->path_list[0] = dirname;
     218
     219                if (!is_path(prefix) && cs->is_command) {
     220                        cs->path_list[0] = malloc(sizeof(char) * PATH_MAX);
     221                        if (cs->path_list[0] == NULL) {
     222                                retval = ENOMEM;
     223                                goto error;
     224                        }
     225
     226                        int ret = snprintf(cs->path_list[0], PATH_MAX, "%s/%s", search_dir[0], dirname);
     227                        if (ret < 0 || ret >= PATH_MAX) {
     228                                retval = ENOMEM;
     229                                goto error;
     230                        }
     231                } else {
     232                        cs->path_list[0] = dirname;
     233                }
     234
     235                free(prefix);
    220236                cs->path_list[1] = NULL;
    221237                /*
  • uspace/app/bdsh/exec.c

    rad40b74b rbc73be3  
    4747#include "errors.h"
    4848
    49 /* FIXME: Just have find_command() return an allocated string */
    50 static char *found;
    51 
    52 static char *find_command(char *);
     49static errno_t find_command(char *, char **);
    5350static int try_access(const char *);
    5451
     
    6865}
    6966
    70 /** Returns the full path of "cmd" if cmd is found
     67/** Returns EOK if no internal failure or else ENOMEM
    7168 *
    72  * else just hand back cmd as it was presented
     69 * When the parameter `cmd` can be found then the absolute path will be set in `found`.
     70 * Or else `found` will be NULL.
     71 * `found` will be newly allocated and must be freed by the caller
    7372 */
    74 static char *find_command(char *cmd)
     73static errno_t find_command(char *cmd, char **found)
    7574{
    76         size_t i;
     75        /* The user has specified a full or relative path, just give it back. */
     76        if (is_path(cmd)) {
     77                if (-1 != try_access(cmd)) {
     78                        *found = str_dup(cmd);
     79                        return EOK;
     80                }
    7781
    78         found = (char *)malloc(PATH_MAX);
     82                *found = NULL;
     83                return EOK;
     84        }
    7985
    80         /* The user has specified a full or relative path, just give it back. */
    81         if (-1 != try_access(cmd)) {
    82                 return (char *) cmd;
     86        *found = (char *)malloc(PATH_MAX);
     87        if (*found == NULL) {
     88                return ENOMEM;
    8389        }
    8490
    8591        /* We now have n places to look for the command */
     92        size_t i;
     93        size_t cmd_length = str_length(cmd);
    8694        for (i = 0; search_dir[i] != NULL; i++) {
    87                 memset(found, 0, PATH_MAX);
    88                 snprintf(found, PATH_MAX, "%s/%s", search_dir[i], cmd);
    89                 if (-1 != try_access(found)) {
    90                         return (char *) found;
     95                if (str_length(search_dir[i]) + cmd_length + 2 > PATH_MAX) {
     96                        free(*found);
     97                        return ENOMEM;
     98                }
     99
     100                memset(*found, 0, PATH_MAX);
     101                snprintf(*found, PATH_MAX, "%s/%s", search_dir[i], cmd);
     102                if (-1 != try_access(*found)) {
     103                        return EOK;
    91104                }
    92105        }
     106        free(*found);
     107        *found = NULL;
    93108
    94         /* We didn't find it, just give it back as-is. */
    95         return (char *) cmd;
     109        /* We didn't find it, return NULL */
     110        return EOK;
    96111}
    97112
     
    107122        FILE *files[3];
    108123
    109         tmp = str_dup(find_command(cmd));
    110         free(found);
     124        rc = find_command(cmd, &tmp);
     125        if (rc != EOK) {
     126                cli_error(CL_ENOMEM, "%s: failure executing find_command()", progname);
     127                return 1;
     128        }
     129
     130        if (tmp == NULL) {
     131                cli_error(CL_EEXEC, "%s: Command not found '%s'", progname, cmd);
     132                return 1;
     133        }
    111134
    112135        files[0] = io->stdin;
  • uspace/app/bdsh/util.c

    rad40b74b rbc73be3  
    7474        return 0;
    7575}
     76
     77/*
     78 * Returns true if the string is a relative or an absolute path
     79 */
     80bool is_path(const char *cmd)
     81{
     82
     83        bool ret = str_lcmp(cmd, "/", 1) == 0;
     84        ret = ret || str_lcmp(cmd, "./", 2) == 0;
     85        ret = ret || str_lcmp(cmd, "../", 3) == 0;
     86
     87        return ret;
     88}
  • uspace/app/bdsh/util.h

    rad40b74b rbc73be3  
    3131
    3232#include "scli.h"
     33#include <stdbool.h>
    3334
    3435/* Utility functions */
    3536extern unsigned int cli_count_args(char **);
    3637extern unsigned int cli_set_prompt(cliuser_t *usr);
     38extern bool is_path(const char *cmd);
    3739
    3840#endif
  • uspace/app/contacts/contacts.c

    rad40b74b rbc73be3  
    526526{
    527527        errno_t rc;
    528         contacts_t *contacts;
     528        contacts_t *contacts = NULL;
    529529
    530530        rc = contacts_open("contacts.sif", &contacts);
  • uspace/app/df/df.c

    rad40b74b rbc73be3  
    7070
    7171        /* Parse command-line options */
    72         while ((optres = getopt(argc, argv, ":ubh")) != -1) {
     72        while ((optres = getopt(argc, argv, "ubh")) != -1) {
    7373                switch (optres) {
    7474                case 'h':
     
    7878                case 'b':
    7979                        display_blocks = true;
    80                         break;
    81 
    82                 case ':':
    83                         fprintf(stderr, "Option -%c requires an operand\n",
    84                             optopt);
    85                         errflg++;
    8680                        break;
    8781
  • uspace/app/dltest/dltest.c

    rad40b74b rbc73be3  
    9191}
    9292
     93/** Test calling function that calls a function that returns a constant */
     94static bool test_dlfcn_dl_get_constant_via_call(void)
     95{
     96        int (*p_dl_get_constant)(void);
     97        int val;
     98
     99        printf("Call dlsym/dl_get_constant_via_call...\n");
     100
     101        p_dl_get_constant = dlsym(handle, "dl_get_constant_via_call");
     102        if (p_dl_get_constant == NULL) {
     103                printf("FAILED\n");
     104                return false;
     105        }
     106
     107        val = p_dl_get_constant();
     108
     109        printf("Got %d, expected %d... ", val, dl_constant);
     110        if (val != dl_constant) {
     111                printf("FAILED\n");
     112                return false;
     113        }
     114
     115        printf("Passed\n");
     116        return true;
     117}
     118
    93119/** Test calling a function that returns contents of a private initialized
    94120 * variable.
     
    564590}
    565591
     592/** Test directly calling function that calls a function that returns a constant */
     593static bool test_lnk_dl_get_constant_via_call(void)
     594{
     595        int val;
     596
     597        printf("Call linked dl_get_constant_via_call...\n");
     598
     599        val = dl_get_constant_via_call();
     600
     601        printf("Got %d, expected %d... ", val, dl_constant);
     602        if (val != dl_constant) {
     603                printf("FAILED\n");
     604                return false;
     605        }
     606
     607        printf("Passed\n");
     608        return true;
     609}
     610
    566611/** Test dircetly calling a function that returns contents of a private
    567612 * initialized variable.
     
    853898                return 1;
    854899
     900        if (!test_dlfcn_dl_get_constant_via_call())
     901                return 1;
     902
    855903        if (!test_dlfcn_dl_get_private_var())
    856904                return 1;
     
    905953{
    906954        if (!test_lnk_dl_get_constant())
     955                return 1;
     956
     957        if (!test_lnk_dl_get_constant_via_call())
    907958                return 1;
    908959
  • uspace/app/fontviewer/fontviewer.c

    rad40b74b rbc73be3  
    4141#include <window.h>
    4242#include <canvas.h>
    43 #include <surface.h>
    44 #include <codec/tga.h>
     43#include <draw/surface.h>
     44#include <draw/codec.h>
    4545#include <task.h>
    46 #include <drawctx.h>
    47 #include <font/embedded.h>
    48 #include <font/pcf.h>
     46#include <draw/drawctx.h>
     47#include <draw/font.h>
    4948#include <stdarg.h>
    5049#include <io/verify.h>
  • uspace/app/hbench/Makefile

    rad40b74b rbc73be3  
    3131LIBS = math
    3232
    33 BINARY = perf
     33BINARY = hbench
    3434
    3535SOURCES = \
    36         perf.c \
     36        benchlist.c \
     37        csv.c \
     38        env.c \
     39        main.c \
     40        utils.c \
     41        fs/dirread.c \
     42        fs/fileread.c \
    3743        ipc/ns_ping.c \
    3844        ipc/ping_pong.c \
    3945        malloc/malloc1.c \
    40         malloc/malloc2.c
     46        malloc/malloc2.c \
     47        synch/fibril_mutex.c
    4148
    4249include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/hbench/ipc/ns_ping.c

    rad40b74b rbc73be3  
    11/*
    2  * Copyright (c) 2012 Petr Koupy
    3  * Copyright (c) 2014 Martin Sucha
     2 * Copyright (c) 2018 Jiri Svoboda
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup draw
     29/** @addtogroup hbench
    3130 * @{
    3231 */
    33 /**
    34  * @file
    35  */
    3632
    37 #ifndef DRAW_FONT_BITMAP_BACKEND_H_
    38 #define DRAW_FONT_BITMAP_BACKEND_H_
     33#include <stdio.h>
     34#include <ns.h>
     35#include <async.h>
     36#include <errno.h>
     37#include <str_error.h>
     38#include "../hbench.h"
    3939
    40 #include <stdint.h>
     40static bool runner(bench_env_t *env, bench_run_t *run, uint64_t niter)
     41{
     42        bench_run_start(run);
    4143
    42 #include "../font.h"
    43 #include "../surface.h"
    44 #include "../source.h"
     44        for (uint64_t count = 0; count < niter; count++) {
     45                errno_t rc = ns_ping();
    4546
    46 typedef struct {
    47         errno_t (*resolve_glyph)(void *, const wchar_t, glyph_id_t *);
    48         errno_t (*load_glyph_surface)(void *, glyph_id_t, surface_t **);
    49         errno_t (*load_glyph_metrics)(void *, glyph_id_t, glyph_metrics_t *);
    50         void (*release)(void *);
    51 } bitmap_font_decoder_t;
     47                if (rc != EOK) {
     48                        return bench_run_fail(run, "failed sending ping message: %s (%d)",
     49                            str_error(rc), rc);
     50                }
     51        }
    5252
    53 extern errno_t bitmap_font_create(bitmap_font_decoder_t *, void *, uint32_t,
    54     font_metrics_t, uint16_t, font_t **);
     53        bench_run_stop(run);
    5554
    56 #endif
     55        return true;
     56}
     57
     58benchmark_t benchmark_ns_ping = {
     59        .name = "ns_ping",
     60        .desc = "Name service IPC ping-pong benchmark",
     61        .entry = &runner,
     62        .setup = NULL,
     63        .teardown = NULL
     64};
    5765
    5866/** @}
  • uspace/app/kio/kio.c

    rad40b74b rbc73be3  
    164164        fibril_mutex_lock(&mtx);
    165165
    166         size_t kio_start = (size_t) IPC_GET_ARG1(*call);
    167         size_t kio_len = (size_t) IPC_GET_ARG2(*call);
    168         size_t kio_stored = (size_t) IPC_GET_ARG3(*call);
     166        size_t kio_start = (size_t) ipc_get_arg1(call);
     167        size_t kio_len = (size_t) ipc_get_arg2(call);
     168        size_t kio_stored = (size_t) ipc_get_arg3(call);
    169169
    170170        size_t offset = (kio_start + kio_len - kio_stored) % kio_length;
  • uspace/app/pci/Makefile

    rad40b74b rbc73be3  
    2828
    2929USPACE_PREFIX = ../..
    30 LIBS = ext4 fs block crypto
    3130BINARY = pci
    3231
  • uspace/app/taskdump/symtab.c

    rad40b74b rbc73be3  
    215215                        continue;
    216216
    217                 stype = ELF_ST_TYPE(st->sym[i].st_info);
     217                stype = elf_st_type(st->sym[i].st_info);
    218218                if (stype != STT_OBJECT && stype != STT_FUNC)
    219219                        continue;
     
    257257                        continue;
    258258
    259                 stype = ELF_ST_TYPE(st->sym[i].st_info);
     259                stype = elf_st_type(st->sym[i].st_info);
    260260                if (stype != STT_OBJECT && stype != STT_FUNC &&
    261261                    stype != STT_NOTYPE) {
  • uspace/app/tester/tester.c

    rad40b74b rbc73be3  
    3535 */
    3636
     37#include <assert.h>
    3738#include <stdio.h>
    3839#include <stddef.h>
     
    4041#include <str.h>
    4142#include <io/log.h>
     43#include <types/casting.h>
    4244#include "tester.h"
    4345
     
    144146        }
    145147
    146         unsigned int _len = (unsigned int) len;
    147         if ((_len != len) || (((int) _len) < 0)) {
    148                 printf("Command length overflow\n");
    149                 return;
    150         }
     148        assert(can_cast_size_t_to_int(len) && "test name length overflow");
    151149
    152150        for (test = tests; test->name != NULL; test++)
    153                 printf("%-*s %s%s\n", _len, test->name, test->desc,
     151                printf("%-*s %s%s\n", (int) len, test->name, test->desc,
    154152                    (test->safe ? "" : " (unsafe)"));
    155153
    156         printf("%-*s Run all safe tests\n", _len, "*");
     154        printf("%-*s Run all safe tests\n", (int) len, "*");
    157155}
    158156
  • uspace/app/trace/ipcp.c

    rad40b74b rbc73be3  
    7272proto_t *proto_unknown;         /**< Protocol with no known methods. */
    7373
    74 static size_t pending_call_key_hash(void *key)
    75 {
    76         cap_call_handle_t *chandle = (cap_call_handle_t *) key;
    77         return CAP_HANDLE_RAW(*chandle);
     74static size_t pending_call_key_hash(const void *key)
     75{
     76        const cap_call_handle_t *chandle = key;
     77        return cap_handle_raw(*chandle);
    7878}
    7979
     
    8181{
    8282        pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link);
    83         return CAP_HANDLE_RAW(hs->call_handle);
    84 }
    85 
    86 static bool pending_call_key_equal(void *key, const ht_link_t *item)
    87 {
    88         cap_call_handle_t *chandle = (cap_call_handle_t *) key;
     83        return cap_handle_raw(hs->call_handle);
     84}
     85
     86static bool pending_call_key_equal(const void *key, const ht_link_t *item)
     87{
     88        const cap_call_handle_t *chandle = key;
    8989        pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link);
    9090
     
    104104        // XXX: there is no longer a limit on the number of phones as phones are
    105105        // now handled using capabilities
    106         if (CAP_HANDLE_RAW(phone) < 0 || CAP_HANDLE_RAW(phone) >= MAX_PHONE)
     106        if (cap_handle_raw(phone) < 0 || cap_handle_raw(phone) >= MAX_PHONE)
    107107                return;
    108         connections[CAP_HANDLE_RAW(phone)].server = server;
    109         connections[CAP_HANDLE_RAW(phone)].proto = proto;
    110         have_conn[CAP_HANDLE_RAW(phone)] = 1;
     108        connections[cap_handle_raw(phone)].server = server;
     109        connections[cap_handle_raw(phone)].proto = proto;
     110        have_conn[cap_handle_raw(phone)] = 1;
    111111}
    112112
    113113void ipcp_connection_clear(cap_phone_handle_t phone)
    114114{
    115         have_conn[CAP_HANDLE_RAW(phone)] = 0;
    116         connections[CAP_HANDLE_RAW(phone)].server = 0;
    117         connections[CAP_HANDLE_RAW(phone)].proto = NULL;
     115        have_conn[cap_handle_raw(phone)] = 0;
     116        connections[cap_handle_raw(phone)].server = 0;
     117        connections[cap_handle_raw(phone)].proto = NULL;
    118118}
    119119
     
    184184        int i;
    185185
    186         if (have_conn[CAP_HANDLE_RAW(phandle)])
    187                 proto = connections[CAP_HANDLE_RAW(phandle)].proto;
     186        if (have_conn[cap_handle_raw(phandle)])
     187                proto = connections[cap_handle_raw(phandle)].proto;
    188188        else
    189189                proto = NULL;
     
    194194                printf("Call handle: %p, phone: %p, proto: %s, method: ",
    195195                    chandle, phandle, (proto ? proto->name : "n/a"));
    196                 ipc_m_print(proto, IPC_GET_IMETHOD(*call));
     196                ipc_m_print(proto, ipc_get_imethod(call));
    197197                printf(" args: (%" PRIun ", %" PRIun ", %" PRIun ", "
    198198                    "%" PRIun ", %" PRIun ")\n",
     
    203203
    204204                if (proto != NULL) {
    205                         oper = proto_get_oper(proto, IPC_GET_IMETHOD(*call));
     205                        oper = proto_get_oper(proto, ipc_get_imethod(call));
    206206                } else {
    207207                        oper = NULL;
     
    262262
    263263        phone = pcall->phone_handle;
    264         method = IPC_GET_IMETHOD(pcall->question);
    265         retval = IPC_GET_RETVAL(*answer);
     264        method = ipc_get_imethod(&pcall->question);
     265        retval = ipc_get_retval(answer);
    266266
    267267        resp = answer->args;
     
    270270                printf("Response to %p: retval=%s, args = (%" PRIun ", "
    271271                    "%" PRIun ", %" PRIun ", %" PRIun ", %" PRIun ")\n",
    272                     call_handle, str_error_name(retval), IPC_GET_ARG1(*answer),
    273                     IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer),
    274                     IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer));
     272                    call_handle, str_error_name(retval), ipc_get_arg1(answer),
     273                    ipc_get_arg2(answer), ipc_get_arg3(answer),
     274                    ipc_get_arg4(answer), ipc_get_arg5(answer));
    275275        }
    276276
     
    305305            (retval == 0)) {
    306306                /* Connected to a service (through NS) */
    307                 service = IPC_GET_ARG2(pcall->question);
     307                service = ipc_get_arg2(&pcall->question);
    308308                proto = proto_get_by_srv(service);
    309309                if (proto == NULL)
    310310                        proto = proto_unknown;
    311311
    312                 cphone = (cap_phone_handle_t) IPC_GET_ARG5(*answer);
     312                cphone = (cap_phone_handle_t) ipc_get_arg5(answer);
    313313                if ((display_mask & DM_SYSTEM) != 0) {
    314314                        printf("Registering connection (phone %p, protocol: %s)\n", cphone,
  • uspace/app/trace/proto.c

    rad40b74b rbc73be3  
    5757/* Hash table operations. */
    5858
    59 static size_t srv_proto_key_hash(void *key)
    60 {
    61         return *(int *)key;
     59static size_t srv_proto_key_hash(const void *key)
     60{
     61        const int *n = key;
     62        return *n;
    6263}
    6364
     
    6869}
    6970
    70 static bool srv_proto_key_equal(void *key, const ht_link_t *item)
    71 {
     71static bool srv_proto_key_equal(const void *key, const ht_link_t *item)
     72{
     73        const int *n = key;
    7274        srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link);
    73         return sp->srv == *(int *)key;
     75        return sp->srv == *n;
    7476}
    7577
     
    8284};
    8385
    84 static size_t method_oper_key_hash(void *key)
    85 {
    86         return *(int *)key;
     86static size_t method_oper_key_hash(const void *key)
     87{
     88        const int *n = key;
     89        return *n;
    8790}
    8891
     
    9396}
    9497
    95 static bool method_oper_key_equal(void *key, const ht_link_t *item)
    96 {
     98static bool method_oper_key_equal(const void *key, const ht_link_t *item)
     99{
     100        const int *n = key;
    97101        method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link);
    98         return mo->method == *(int *)key;
     102        return mo->method == *n;
    99103}
    100104
  • uspace/app/trace/trace.c

    rad40b74b rbc73be3  
    302302        phandle = (cap_phone_handle_t) sc_args[0];
    303303
    304         IPC_SET_IMETHOD(call, sc_args[1]);
    305         IPC_SET_ARG1(call, sc_args[2]);
    306         IPC_SET_ARG2(call, sc_args[3]);
    307         IPC_SET_ARG3(call, sc_args[4]);
    308         IPC_SET_ARG4(call, sc_args[5]);
    309         IPC_SET_ARG5(call, 0);
     304        ipc_set_imethod(&call, sc_args[1]);
     305        ipc_set_arg1(&call, sc_args[2]);
     306        ipc_set_arg2(&call, sc_args[3]);
     307        ipc_set_arg3(&call, sc_args[4]);
     308        ipc_set_arg4(&call, sc_args[5]);
     309        ipc_set_arg5(&call, 0);
    310310
    311311        ipcp_call_out(phandle, &call, 0);
  • uspace/app/viewer/viewer.c

    rad40b74b rbc73be3  
    4141#include <window.h>
    4242#include <canvas.h>
    43 #include <surface.h>
    44 #include <codec/tga.h>
     43#include <draw/surface.h>
     44#include <draw/codec.h>
    4545#include <task.h>
    4646#include <str.h>
  • uspace/app/vlaunch/vlaunch.c

    rad40b74b rbc73be3  
    4646#include <canvas.h>
    4747
    48 #include <surface.h>
    49 #include <source.h>
    50 #include <drawctx.h>
    51 #include <codec/tga.h>
     48#include <draw/surface.h>
     49#include <draw/source.h>
     50#include <draw/drawctx.h>
     51#include <draw/codec.h>
    5252
    5353#include "images.h"
  • uspace/app/wavplay/dplay.c

    rad40b74b rbc73be3  
    103103                async_get_call(&call);
    104104
    105                 switch (IPC_GET_IMETHOD(call)) {
     105                switch (ipc_get_imethod(&call)) {
    106106                case PCM_EVENT_PLAYBACK_STARTED:
    107107                case PCM_EVENT_FRAMES_PLAYED:
    108                         printf("%" PRIun " frames: ", IPC_GET_ARG1(call));
     108                        printf("%" PRIun " frames: ", ipc_get_arg1(&call));
    109109                        async_answer_0(&call, EOK);
    110110                        break;
     
    118118                        return;
    119119                default:
    120                         printf("Unknown event %" PRIun ".\n", IPC_GET_IMETHOD(call));
     120                        printf("Unknown event %" PRIun ".\n", ipc_get_imethod(&call));
    121121                        async_answer_0(&call, ENOTSUP);
    122122                        continue;
  • uspace/app/wavplay/drec.c

    rad40b74b rbc73be3  
    103103                async_get_call(&call);
    104104
    105                 switch (IPC_GET_IMETHOD(call)) {
     105                switch (ipc_get_imethod(&call)) {
    106106                case PCM_EVENT_CAPTURE_TERMINATED:
    107107                        printf("Recording terminated\n");
     
    109109                        break;
    110110                case PCM_EVENT_FRAMES_CAPTURED:
    111                         printf("%" PRIun " frames\n", IPC_GET_ARG1(call));
     111                        printf("%" PRIun " frames\n", ipc_get_arg1(&call));
    112112                        break;
    113113                default:
    114                         printf("Unknown event %" PRIun ".\n", IPC_GET_IMETHOD(call));
     114                        printf("Unknown event %" PRIun ".\n", ipc_get_imethod(&call));
    115115                        async_answer_0(&call, ENOTSUP);
    116116                        continue;
Note: See TracChangeset for help on using the changeset viewer.