Changeset bc73be3 in mainline for uspace/app
- Timestamp:
- 2019-06-27T08:51:20Z (7 years ago)
- 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. - Location:
- uspace/app
- Files:
-
- 17 added
- 12 deleted
- 28 edited
- 2 moved
-
barber/barber.c (modified) (1 diff)
-
bdsh/Makefile (modified) (2 diffs)
-
bdsh/cmds/builtins/builtin_aliases.c (added)
-
bdsh/cmds/builtins/builtin_aliases.h (modified) (1 diff)
-
bdsh/cmds/builtins/builtins.c (added)
-
bdsh/cmds/builtins/builtins.h (modified) (1 diff)
-
bdsh/cmds/mknewcmd (modified) (1 diff)
-
bdsh/cmds/modules/ls/ls.c (modified) (12 diffs)
-
bdsh/cmds/modules/ls/ls.h (modified) (2 diffs)
-
bdsh/cmds/modules/module_aliases.c (added)
-
bdsh/cmds/modules/module_aliases.h (modified) (1 diff)
-
bdsh/cmds/modules/modules.c (added)
-
bdsh/cmds/modules/modules.h (modified) (1 diff)
-
bdsh/compl.c (modified) (3 diffs)
-
bdsh/exec.c (modified) (3 diffs)
-
bdsh/util.c (modified) (1 diff)
-
bdsh/util.h (modified) (1 diff)
-
bnchmark/bnchmark.c (deleted)
-
bnchmark/doc/doxygroups.h (deleted)
-
contacts/contacts.c (modified) (1 diff)
-
df/df.c (modified) (2 diffs)
-
dltest/dltest.c (modified) (4 diffs)
-
fontviewer/fontviewer.c (modified) (1 diff)
-
hbench/Makefile (moved) (moved from uspace/app/perf/Makefile ) (1 diff)
-
hbench/benchlist.c (added)
-
hbench/csv.c (added)
-
hbench/doc/doxygroups.h (added)
-
hbench/env.c (added)
-
hbench/fs/dirread.c (added)
-
hbench/fs/fileread.c (added)
-
hbench/hbench.h (added)
-
hbench/ipc/ns_ping.c (moved) (moved from uspace/lib/draw/font/bitmap_backend.h ) (2 diffs)
-
hbench/ipc/ping_pong.c (added)
-
hbench/main.c (added)
-
hbench/malloc/malloc1.c (added)
-
hbench/malloc/malloc2.c (added)
-
hbench/synch/fibril_mutex.c (added)
-
hbench/utils.c (added)
-
kio/kio.c (modified) (1 diff)
-
pci/Makefile (modified) (1 diff)
-
perf/doc/doxygroups.h (deleted)
-
perf/ipc/ns_ping.c (deleted)
-
perf/ipc/ns_ping.def (deleted)
-
perf/ipc/ping_pong.c (deleted)
-
perf/ipc/ping_pong.def (deleted)
-
perf/malloc/malloc1.c (deleted)
-
perf/malloc/malloc1.def (deleted)
-
perf/malloc/malloc2.c (deleted)
-
perf/malloc/malloc2.def (deleted)
-
perf/perf.c (deleted)
-
taskdump/symtab.c (modified) (2 diffs)
-
tester/tester.c (modified) (3 diffs)
-
trace/ipcp.c (modified) (9 diffs)
-
trace/proto.c (modified) (4 diffs)
-
trace/trace.c (modified) (1 diff)
-
viewer/viewer.c (modified) (1 diff)
-
vlaunch/vlaunch.c (modified) (1 diff)
-
wavplay/dplay.c (modified) (2 diffs)
-
wavplay/drec.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/barber/barber.c
rad40b74b rbc73be3 45 45 #include <window.h> 46 46 #include <canvas.h> 47 #include < surface.h>48 #include < codec/tga.gz.h>47 #include <draw/surface.h> 48 #include <draw/codec.h> 49 49 #include "images.h" 50 50 -
uspace/app/bdsh/Makefile
rad40b74b rbc73be3 34 34 35 35 SOURCES = \ 36 cmds/modules/module_aliases.c \ 37 cmds/modules/modules.c \ 36 38 cmds/modules/help/help.c \ 37 39 cmds/modules/mkdir/mkdir.c \ … … 51 53 cmds/modules/kcon/kcon.c \ 52 54 cmds/modules/cmp/cmp.c \ 55 cmds/builtins/builtin_aliases.c \ 56 cmds/builtins/builtins.c \ 53 57 cmds/builtins/batch/batch.c \ 54 58 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 1 29 #ifndef BUILTIN_ALIASES_H 2 30 #define BUILTIN_ALIASES_H 3 31 4 /* See modules/module_aliases.h for an explanation of this file */ 5 6 char *builtin_aliases[] = { 7 NULL, NULL 8 }; 32 extern char *builtin_aliases[]; 9 33 10 34 #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 1 29 #ifndef BUILTINS_H 2 30 #define BUILTINS_H 3 31 4 #include " config.h"32 #include "../cmds.h" 5 33 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 }; 34 extern builtin_t builtins[]; 16 35 17 36 #endif -
uspace/app/bdsh/cmds/mknewcmd
rad40b74b rbc73be3 213 213 printf " to include your new command.\n" 214 214 [ -n "$CMDALIAS" ] && { 215 printf "\nYou should also modify %ss/%s_aliases. hand " \215 printf "\nYou should also modify %ss/%s_aliases.c and " \ 216 216 "${CMDTYPE}" "${CMDTYPE}" 217 217 printf "add %s as an alias for %s\n" \ -
uspace/app/bdsh/cmds/modules/ls/ls.c
rad40b74b rbc73be3 42 42 #include <vfs/vfs.h> 43 43 #include <str.h> 44 #include <cap.h> 44 45 45 46 #include "ls.h" … … 58 59 { "unsort", no_argument, 0, 'u' }, 59 60 { "recursive", no_argument, 0, 'r' }, 61 { "exact-size", no_argument, 0, 'e' }, 62 { "single-column", no_argument, 0, '1' }, 60 63 { 0, 0, 0, 0 } 61 64 }; … … 63 66 /* Prototypes for the ls command, excluding entry points. */ 64 67 static 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 *); 68 static errno_t ls_print(struct dir_elem_t *); 69 static errno_t ls_print_single_column(struct dir_elem_t *); 70 static int ls_cmp_type_name(const void *, const void *); 71 static int ls_cmp_name(const void *, const void *); 67 72 static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **); 68 73 static unsigned int ls_recursive(const char *, DIR *); … … 74 79 ls->sort = 1; 75 80 81 ls->exact_size = false; 82 ls->single_column = false; 83 ls->printer = ls_print; 76 84 return 1; 77 85 } … … 88 96 * @param de Directory element. 89 97 */ 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); 98 static 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>"); 96 130 else 97 131 printf("%-40s\n", de->name); 132 133 return EOK; 134 } 135 136 static 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; 98 145 } 99 146 … … 109 156 * @return -1 if a < b, 1 otherwise. 110 157 */ 111 static int ls_cmp (const void *a, const void *b)158 static int ls_cmp_type_name(const void *a, const void *b) 112 159 { 113 160 struct dir_elem_t const *da = a; … … 120 167 else 121 168 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 */ 177 static 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); 122 183 } 123 184 … … 192 253 } 193 254 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 } 199 267 200 268 /* Populate the directory list. */ … … 333 401 "If not path is given, the current working directory is used.\n" 334 402 "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", 338 408 cmdname); 339 409 } … … 364 434 365 435 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); 367 437 switch (c) { 368 438 case 'h': … … 375 445 ls.recursive = 1; 376 446 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; 377 454 } 378 455 } … … 400 477 switch (scope) { 401 478 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 } 403 483 break; 404 484 case LS_DIR: -
uspace/app/bdsh/cmds/modules/ls/ls.h
rad40b74b rbc73be3 8 8 #define LS_FILE 1 9 9 #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;17 10 18 11 /** Structure to represent a directory entry. … … 26 19 }; 27 20 21 typedef 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 28 32 #endif -
uspace/app/bdsh/cmds/modules/module_aliases.h
rad40b74b rbc73be3 30 30 #define MODULE_ALIASES_H 31 31 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 }; 32 extern const char *mod_aliases[]; 51 33 52 34 #endif -
uspace/app/bdsh/cmds/modules/modules.h
rad40b74b rbc73be3 30 30 #define MODULES_H 31 31 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" 45 34 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 }; 35 extern module_t modules[]; 95 36 96 37 #endif -
uspace/app/bdsh/compl.c
rad40b74b rbc73be3 40 40 #include "exec.h" 41 41 #include "tok.h" 42 #include "util.h" 42 43 43 44 static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state); … … 209 210 } 210 211 *cstart += rpath_sep + 1 - prefix; 211 free(prefix);212 prefix = NULL;213 212 214 213 cs->path_list = malloc(sizeof(char *) * 2); … … 217 216 goto error; 218 217 } 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); 220 236 cs->path_list[1] = NULL; 221 237 /* -
uspace/app/bdsh/exec.c
rad40b74b rbc73be3 47 47 #include "errors.h" 48 48 49 /* FIXME: Just have find_command() return an allocated string */ 50 static char *found; 51 52 static char *find_command(char *); 49 static errno_t find_command(char *, char **); 53 50 static int try_access(const char *); 54 51 … … 68 65 } 69 66 70 /** Returns the full path of "cmd" if cmd is found67 /** Returns EOK if no internal failure or else ENOMEM 71 68 * 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 73 72 */ 74 static char *find_command(char *cmd)73 static errno_t find_command(char *cmd, char **found) 75 74 { 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 } 77 81 78 found = (char *)malloc(PATH_MAX); 82 *found = NULL; 83 return EOK; 84 } 79 85 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; 83 89 } 84 90 85 91 /* We now have n places to look for the command */ 92 size_t i; 93 size_t cmd_length = str_length(cmd); 86 94 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; 91 104 } 92 105 } 106 free(*found); 107 *found = NULL; 93 108 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; 96 111 } 97 112 … … 107 122 FILE *files[3]; 108 123 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 } 111 134 112 135 files[0] = io->stdin; -
uspace/app/bdsh/util.c
rad40b74b rbc73be3 74 74 return 0; 75 75 } 76 77 /* 78 * Returns true if the string is a relative or an absolute path 79 */ 80 bool 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 31 31 32 32 #include "scli.h" 33 #include <stdbool.h> 33 34 34 35 /* Utility functions */ 35 36 extern unsigned int cli_count_args(char **); 36 37 extern unsigned int cli_set_prompt(cliuser_t *usr); 38 extern bool is_path(const char *cmd); 37 39 38 40 #endif -
uspace/app/contacts/contacts.c
rad40b74b rbc73be3 526 526 { 527 527 errno_t rc; 528 contacts_t *contacts ;528 contacts_t *contacts = NULL; 529 529 530 530 rc = contacts_open("contacts.sif", &contacts); -
uspace/app/df/df.c
rad40b74b rbc73be3 70 70 71 71 /* Parse command-line options */ 72 while ((optres = getopt(argc, argv, " :ubh")) != -1) {72 while ((optres = getopt(argc, argv, "ubh")) != -1) { 73 73 switch (optres) { 74 74 case 'h': … … 78 78 case 'b': 79 79 display_blocks = true; 80 break;81 82 case ':':83 fprintf(stderr, "Option -%c requires an operand\n",84 optopt);85 errflg++;86 80 break; 87 81 -
uspace/app/dltest/dltest.c
rad40b74b rbc73be3 91 91 } 92 92 93 /** Test calling function that calls a function that returns a constant */ 94 static 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 93 119 /** Test calling a function that returns contents of a private initialized 94 120 * variable. … … 564 590 } 565 591 592 /** Test directly calling function that calls a function that returns a constant */ 593 static 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 566 611 /** Test dircetly calling a function that returns contents of a private 567 612 * initialized variable. … … 853 898 return 1; 854 899 900 if (!test_dlfcn_dl_get_constant_via_call()) 901 return 1; 902 855 903 if (!test_dlfcn_dl_get_private_var()) 856 904 return 1; … … 905 953 { 906 954 if (!test_lnk_dl_get_constant()) 955 return 1; 956 957 if (!test_lnk_dl_get_constant_via_call()) 907 958 return 1; 908 959 -
uspace/app/fontviewer/fontviewer.c
rad40b74b rbc73be3 41 41 #include <window.h> 42 42 #include <canvas.h> 43 #include < surface.h>44 #include < codec/tga.h>43 #include <draw/surface.h> 44 #include <draw/codec.h> 45 45 #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> 49 48 #include <stdarg.h> 50 49 #include <io/verify.h> -
uspace/app/hbench/Makefile
rad40b74b rbc73be3 31 31 LIBS = math 32 32 33 BINARY = perf33 BINARY = hbench 34 34 35 35 SOURCES = \ 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 \ 37 43 ipc/ns_ping.c \ 38 44 ipc/ping_pong.c \ 39 45 malloc/malloc1.c \ 40 malloc/malloc2.c 46 malloc/malloc2.c \ 47 synch/fibril_mutex.c 41 48 42 49 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/hbench/ipc/ns_ping.c
rad40b74b rbc73be3 1 1 /* 2 * Copyright (c) 2012 Petr Koupy 3 * Copyright (c) 2014 Martin Sucha 2 * Copyright (c) 2018 Jiri Svoboda 4 3 * All rights reserved. 5 4 * … … 28 27 */ 29 28 30 /** @addtogroup draw29 /** @addtogroup hbench 31 30 * @{ 32 31 */ 33 /**34 * @file35 */36 32 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" 39 39 40 #include <stdint.h> 40 static bool runner(bench_env_t *env, bench_run_t *run, uint64_t niter) 41 { 42 bench_run_start(run); 41 43 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(); 45 46 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 } 52 52 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); 55 54 56 #endif 55 return true; 56 } 57 58 benchmark_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 }; 57 65 58 66 /** @} -
uspace/app/kio/kio.c
rad40b74b rbc73be3 164 164 fibril_mutex_lock(&mtx); 165 165 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); 169 169 170 170 size_t offset = (kio_start + kio_len - kio_stored) % kio_length; -
uspace/app/pci/Makefile
rad40b74b rbc73be3 28 28 29 29 USPACE_PREFIX = ../.. 30 LIBS = ext4 fs block crypto31 30 BINARY = pci 32 31 -
uspace/app/taskdump/symtab.c
rad40b74b rbc73be3 215 215 continue; 216 216 217 stype = ELF_ST_TYPE(st->sym[i].st_info);217 stype = elf_st_type(st->sym[i].st_info); 218 218 if (stype != STT_OBJECT && stype != STT_FUNC) 219 219 continue; … … 257 257 continue; 258 258 259 stype = ELF_ST_TYPE(st->sym[i].st_info);259 stype = elf_st_type(st->sym[i].st_info); 260 260 if (stype != STT_OBJECT && stype != STT_FUNC && 261 261 stype != STT_NOTYPE) { -
uspace/app/tester/tester.c
rad40b74b rbc73be3 35 35 */ 36 36 37 #include <assert.h> 37 38 #include <stdio.h> 38 39 #include <stddef.h> … … 40 41 #include <str.h> 41 42 #include <io/log.h> 43 #include <types/casting.h> 42 44 #include "tester.h" 43 45 … … 144 146 } 145 147 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"); 151 149 152 150 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, 154 152 (test->safe ? "" : " (unsafe)")); 155 153 156 printf("%-*s Run all safe tests\n", _len, "*");154 printf("%-*s Run all safe tests\n", (int) len, "*"); 157 155 } 158 156 -
uspace/app/trace/ipcp.c
rad40b74b rbc73be3 72 72 proto_t *proto_unknown; /**< Protocol with no known methods. */ 73 73 74 static size_t pending_call_key_hash( void *key)75 { 76 c ap_call_handle_t *chandle = (cap_call_handle_t *)key;77 return CAP_HANDLE_RAW(*chandle);74 static size_t pending_call_key_hash(const void *key) 75 { 76 const cap_call_handle_t *chandle = key; 77 return cap_handle_raw(*chandle); 78 78 } 79 79 … … 81 81 { 82 82 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 c ap_call_handle_t *chandle = (cap_call_handle_t *)key;83 return cap_handle_raw(hs->call_handle); 84 } 85 86 static bool pending_call_key_equal(const void *key, const ht_link_t *item) 87 { 88 const cap_call_handle_t *chandle = key; 89 89 pending_call_t *hs = hash_table_get_inst(item, pending_call_t, link); 90 90 … … 104 104 // XXX: there is no longer a limit on the number of phones as phones are 105 105 // 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) 107 107 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; 111 111 } 112 112 113 113 void ipcp_connection_clear(cap_phone_handle_t phone) 114 114 { 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; 118 118 } 119 119 … … 184 184 int i; 185 185 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; 188 188 else 189 189 proto = NULL; … … 194 194 printf("Call handle: %p, phone: %p, proto: %s, method: ", 195 195 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)); 197 197 printf(" args: (%" PRIun ", %" PRIun ", %" PRIun ", " 198 198 "%" PRIun ", %" PRIun ")\n", … … 203 203 204 204 if (proto != NULL) { 205 oper = proto_get_oper(proto, IPC_GET_IMETHOD(*call));205 oper = proto_get_oper(proto, ipc_get_imethod(call)); 206 206 } else { 207 207 oper = NULL; … … 262 262 263 263 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); 266 266 267 267 resp = answer->args; … … 270 270 printf("Response to %p: retval=%s, args = (%" PRIun ", " 271 271 "%" 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)); 275 275 } 276 276 … … 305 305 (retval == 0)) { 306 306 /* Connected to a service (through NS) */ 307 service = IPC_GET_ARG2(pcall->question);307 service = ipc_get_arg2(&pcall->question); 308 308 proto = proto_get_by_srv(service); 309 309 if (proto == NULL) 310 310 proto = proto_unknown; 311 311 312 cphone = (cap_phone_handle_t) IPC_GET_ARG5(*answer);312 cphone = (cap_phone_handle_t) ipc_get_arg5(answer); 313 313 if ((display_mask & DM_SYSTEM) != 0) { 314 314 printf("Registering connection (phone %p, protocol: %s)\n", cphone, -
uspace/app/trace/proto.c
rad40b74b rbc73be3 57 57 /* Hash table operations. */ 58 58 59 static size_t srv_proto_key_hash(void *key) 60 { 61 return *(int *)key; 59 static size_t srv_proto_key_hash(const void *key) 60 { 61 const int *n = key; 62 return *n; 62 63 } 63 64 … … 68 69 } 69 70 70 static bool srv_proto_key_equal(void *key, const ht_link_t *item) 71 { 71 static bool srv_proto_key_equal(const void *key, const ht_link_t *item) 72 { 73 const int *n = key; 72 74 srv_proto_t *sp = hash_table_get_inst(item, srv_proto_t, link); 73 return sp->srv == * (int *)key;75 return sp->srv == *n; 74 76 } 75 77 … … 82 84 }; 83 85 84 static size_t method_oper_key_hash(void *key) 85 { 86 return *(int *)key; 86 static size_t method_oper_key_hash(const void *key) 87 { 88 const int *n = key; 89 return *n; 87 90 } 88 91 … … 93 96 } 94 97 95 static bool method_oper_key_equal(void *key, const ht_link_t *item) 96 { 98 static bool method_oper_key_equal(const void *key, const ht_link_t *item) 99 { 100 const int *n = key; 97 101 method_oper_t *mo = hash_table_get_inst(item, method_oper_t, link); 98 return mo->method == * (int *)key;102 return mo->method == *n; 99 103 } 100 104 -
uspace/app/trace/trace.c
rad40b74b rbc73be3 302 302 phandle = (cap_phone_handle_t) sc_args[0]; 303 303 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); 310 310 311 311 ipcp_call_out(phandle, &call, 0); -
uspace/app/viewer/viewer.c
rad40b74b rbc73be3 41 41 #include <window.h> 42 42 #include <canvas.h> 43 #include < surface.h>44 #include < codec/tga.h>43 #include <draw/surface.h> 44 #include <draw/codec.h> 45 45 #include <task.h> 46 46 #include <str.h> -
uspace/app/vlaunch/vlaunch.c
rad40b74b rbc73be3 46 46 #include <canvas.h> 47 47 48 #include < surface.h>49 #include < source.h>50 #include <draw ctx.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> 52 52 53 53 #include "images.h" -
uspace/app/wavplay/dplay.c
rad40b74b rbc73be3 103 103 async_get_call(&call); 104 104 105 switch ( IPC_GET_IMETHOD(call)) {105 switch (ipc_get_imethod(&call)) { 106 106 case PCM_EVENT_PLAYBACK_STARTED: 107 107 case PCM_EVENT_FRAMES_PLAYED: 108 printf("%" PRIun " frames: ", IPC_GET_ARG1(call));108 printf("%" PRIun " frames: ", ipc_get_arg1(&call)); 109 109 async_answer_0(&call, EOK); 110 110 break; … … 118 118 return; 119 119 default: 120 printf("Unknown event %" PRIun ".\n", IPC_GET_IMETHOD(call));120 printf("Unknown event %" PRIun ".\n", ipc_get_imethod(&call)); 121 121 async_answer_0(&call, ENOTSUP); 122 122 continue; -
uspace/app/wavplay/drec.c
rad40b74b rbc73be3 103 103 async_get_call(&call); 104 104 105 switch ( IPC_GET_IMETHOD(call)) {105 switch (ipc_get_imethod(&call)) { 106 106 case PCM_EVENT_CAPTURE_TERMINATED: 107 107 printf("Recording terminated\n"); … … 109 109 break; 110 110 case PCM_EVENT_FRAMES_CAPTURED: 111 printf("%" PRIun " frames\n", IPC_GET_ARG1(call));111 printf("%" PRIun " frames\n", ipc_get_arg1(&call)); 112 112 break; 113 113 default: 114 printf("Unknown event %" PRIun ".\n", IPC_GET_IMETHOD(call));114 printf("Unknown event %" PRIun ".\n", ipc_get_imethod(&call)); 115 115 async_answer_0(&call, ENOTSUP); 116 116 continue;
Note:
See TracChangeset
for help on using the changeset viewer.
