Changeset 2b3dd78 in mainline for uspace/lib/c/generic
- Timestamp:
- 2018-01-31T12:02:00Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5595841
- Parents:
- a0a9cc2 (diff), 14d789c (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/lib/c/generic
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/getopt.c
ra0a9cc2 r2b3dd78 49 49 int optopt = '?'; /* character checked for validity */ 50 50 int optreset; /* reset getopt */ 51 c onst char*optarg; /* argument associated with option */51 char *optarg; /* argument associated with option */ 52 52 53 53 … … 67 67 #define INORDER (int)1 68 68 69 #define EMSG "" 69 static char EMSG[] = ""; 70 70 71 71 static int getopt_internal(int, char **, const char *); … … 73 73 static void permute_args(int, int, int, char **); 74 74 75 static c onst char *place = EMSG; /* option letter processing */75 static char *place = EMSG; /* option letter processing */ 76 76 77 77 /* XXX: set optreset to 1 rather than these two */ … … 336 336 if (retval == -2) { 337 337 char *current_argv; 338 c onst char *has_equal;338 char *has_equal; 339 339 size_t current_argv_len; 340 340 int i, ambiguous, match; -
uspace/lib/c/generic/inet/addr.c
ra0a9cc2 r2b3dd78 42 42 #include <bitops.h> 43 43 #include <inttypes.h> 44 #include <str.h> 44 45 45 46 #define INET_PREFIXSTRSIZE 5 -
uspace/lib/c/generic/io/io.c
ra0a9cc2 r2b3dd78 799 799 } 800 800 801 int fseek (FILE *stream, longoffset, int whence)801 int fseek64(FILE *stream, off64_t offset, int whence) 802 802 { 803 803 errno_t rc; … … 814 814 stream->ungetc_chars = 0; 815 815 816 struct stat st;816 vfs_stat_t st; 817 817 switch (whence) { 818 818 case SEEK_SET: … … 837 837 } 838 838 839 long ftell(FILE *stream) 840 { 841 /* The native position is too large for the C99-ish interface. */ 842 if (stream->pos - stream->ungetc_chars > LONG_MAX) 843 return EOF; 844 839 off64_t ftell64(FILE *stream) 840 { 845 841 if (stream->error) 846 842 return EOF; … … 853 849 854 850 return stream->pos - stream->ungetc_chars; 851 } 852 853 int fseek(FILE *stream, long offset, int whence) 854 { 855 return fseek64(stream, offset, whence); 856 } 857 858 long ftell(FILE *stream) 859 { 860 off64_t off = ftell64(stream); 861 862 /* The native position is too large for the C99-ish interface. */ 863 if (off > LONG_MAX) 864 return EOF; 865 866 return off; 855 867 } 856 868 -
uspace/lib/c/generic/io/log.c
ra0a9cc2 r2b3dd78 41 41 #include <io/log.h> 42 42 #include <ipc/logger.h> 43 #include <str.h> 43 44 #include <ns.h> 44 45 -
uspace/lib/c/generic/io/table.c
ra0a9cc2 r2b3dd78 40 40 #include <stdio.h> 41 41 #include <stdlib.h> 42 #include <str.h> 42 43 43 44 static table_column_t *table_column_first(table_t *); -
uspace/lib/c/generic/malloc.c
ra0a9cc2 r2b3dd78 33 33 /** @file 34 34 */ 35 36 #define _HELENOS_SOURCE37 35 38 36 #include <malloc.h> … … 876 874 * 877 875 */ 878 void *realloc(const void *addr, const size_t size) 879 { 876 void *realloc(void * const addr, const size_t size) 877 { 878 if (size == 0) { 879 free(addr); 880 return NULL; 881 } 882 880 883 if (addr == NULL) 881 884 return malloc(size); … … 985 988 * 986 989 */ 987 void free( const void *addr)990 void free(void * const addr) 988 991 { 989 992 if (addr == NULL) -
uspace/lib/c/generic/rtld/dynamic.c
ra0a9cc2 r2b3dd78 37 37 #include <stdio.h> 38 38 #include <inttypes.h> 39 #include <str.h> 39 40 40 41 #include <rtld/elf_dyn.h> -
uspace/lib/c/generic/rtld/module.c
ra0a9cc2 r2b3dd78 41 41 #include <stdio.h> 42 42 #include <stdlib.h> 43 #include <str.h> 43 44 44 45 #include <rtld/rtld.h> -
uspace/lib/c/generic/rtld/rtld.c
ra0a9cc2 r2b3dd78 40 40 #include <rtld/rtld_debug.h> 41 41 #include <stdlib.h> 42 #include <str.h> 42 43 43 44 rtld_t *runtime_env; -
uspace/lib/c/generic/rtld/symbol.c
ra0a9cc2 r2b3dd78 37 37 #include <stdio.h> 38 38 #include <stdlib.h> 39 #include <str.h> 39 40 40 41 #include <elf/elf.h> -
uspace/lib/c/generic/stdlib.c
ra0a9cc2 r2b3dd78 35 35 #include <stdlib.h> 36 36 37 static longglbl_seed = 1;37 static int glbl_seed = 1; 38 38 39 long int random(void)39 int rand(void) 40 40 { 41 41 return glbl_seed = ((1366 * glbl_seed + 150889) % RAND_MAX); 42 42 } 43 43 44 void srand om(unsigned int seed)44 void srand(unsigned int seed) 45 45 { 46 46 glbl_seed = seed % RAND_MAX; -
uspace/lib/c/generic/str.c
ra0a9cc2 r2b3dd78 1273 1273 } 1274 1274 1275 /** Convert string to a number.1276 * Core of strtol and strtoul functions.1277 *1278 * @param nptr Pointer to string.1279 * @param endptr If not NULL, function stores here pointer to the first1280 * invalid character.1281 * @param base Zero or number between 2 and 36 inclusive.1282 * @param sgn It's set to 1 if minus found.1283 * @return Result of conversion.1284 */1285 static unsigned long1286 _strtoul(const char *nptr, char **endptr, int base, char *sgn)1287 {1288 unsigned char c;1289 unsigned long result = 0;1290 unsigned long a, b;1291 const char *str = nptr;1292 const char *tmpptr;1293 1294 while (isspace(*str))1295 str++;1296 1297 if (*str == '-') {1298 *sgn = 1;1299 ++str;1300 } else if (*str == '+')1301 ++str;1302 1303 if (base) {1304 if ((base == 1) || (base > 36)) {1305 /* FIXME: set errno to EINVAL */1306 return 0;1307 }1308 if ((base == 16) && (*str == '0') && ((str[1] == 'x') ||1309 (str[1] == 'X'))) {1310 str += 2;1311 }1312 } else {1313 base = 10;1314 1315 if (*str == '0') {1316 base = 8;1317 if ((str[1] == 'X') || (str[1] == 'x')) {1318 base = 16;1319 str += 2;1320 }1321 }1322 }1323 1324 tmpptr = str;1325 1326 while (*str) {1327 c = *str;1328 c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 :1329 (c <= '9' ? c - '0' : 0xff)));1330 if (c >= base) {1331 break;1332 }1333 1334 a = (result & 0xff) * base + c;1335 b = (result >> 8) * base + (a >> 8);1336 1337 if (b > (ULONG_MAX >> 8)) {1338 /* overflow */1339 /* FIXME: errno = ERANGE*/1340 return ULONG_MAX;1341 }1342 1343 result = (b << 8) + (a & 0xff);1344 ++str;1345 }1346 1347 if (str == tmpptr) {1348 /*1349 * No number was found => first invalid character is the first1350 * character of the string.1351 */1352 /* FIXME: set errno to EINVAL */1353 str = nptr;1354 result = 0;1355 }1356 1357 if (endptr)1358 *endptr = (char *) str;1359 1360 if (nptr == str) {1361 /*FIXME: errno = EINVAL*/1362 return 0;1363 }1364 1365 return result;1366 }1367 1368 /** Convert initial part of string to long int according to given base.1369 * The number may begin with an arbitrary number of whitespaces followed by1370 * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be1371 * inserted and the number will be taken as hexadecimal one. If the base is 01372 * and the number begin with a zero, number will be taken as octal one (as with1373 * base 8). Otherwise the base 0 is taken as decimal.1374 *1375 * @param nptr Pointer to string.1376 * @param endptr If not NULL, function stores here pointer to the first1377 * invalid character.1378 * @param base Zero or number between 2 and 36 inclusive.1379 * @return Result of conversion.1380 */1381 long int strtol(const char *nptr, char **endptr, int base)1382 {1383 char sgn = 0;1384 unsigned long number = 0;1385 1386 number = _strtoul(nptr, endptr, base, &sgn);1387 1388 if (number > LONG_MAX) {1389 if ((sgn) && (number == (unsigned long) (LONG_MAX) + 1)) {1390 /* FIXME: set 0 to errno */1391 return number;1392 }1393 /* FIXME: set ERANGE to errno */1394 return (sgn ? LONG_MIN : LONG_MAX);1395 }1396 1397 return (sgn ? -number : number);1398 }1399 1275 1400 1276 /** Duplicate string. … … 1457 1333 str_ncpy(dest, size + 1, src, size); 1458 1334 return dest; 1459 }1460 1461 /** Convert initial part of string to unsigned long according to given base.1462 * The number may begin with an arbitrary number of whitespaces followed by1463 * optional sign (`+' or `-'). If the base is 0 or 16, the prefix `0x' may be1464 * inserted and the number will be taken as hexadecimal one. If the base is 01465 * and the number begin with a zero, number will be taken as octal one (as with1466 * base 8). Otherwise the base 0 is taken as decimal.1467 *1468 * @param nptr Pointer to string.1469 * @param endptr If not NULL, function stores here pointer to the first1470 * invalid character1471 * @param base Zero or number between 2 and 36 inclusive.1472 * @return Result of conversion.1473 */1474 unsigned long strtoul(const char *nptr, char **endptr, int base)1475 {1476 char sgn = 0;1477 unsigned long number = 0;1478 1479 number = _strtoul(nptr, endptr, base, &sgn);1480 1481 return (sgn ? -number : number);1482 1335 } 1483 1336 -
uspace/lib/c/generic/uuid.c
ra0a9cc2 r2b3dd78 52 52 /* XXX This is a rather poor way of generating random numbers */ 53 53 gettimeofday(&tv, NULL); 54 srand om(tv.tv_sec ^ tv.tv_usec);54 srand(tv.tv_sec ^ tv.tv_usec); 55 55 56 56 for (i = 0; i < uuid_bytes; i++) 57 uuid->b[i] = rand om();57 uuid->b[i] = rand(); 58 58 59 59 /* Version 4 UUID from random or pseudo-random numbers */ -
uspace/lib/c/generic/vfs/mtab.c
ra0a9cc2 r2b3dd78 40 40 #include <errno.h> 41 41 #include <assert.h> 42 #include <str.h> 42 43 43 static void process_mp(const char *path, struct stat *stat, list_t *mtab_list)44 static void process_mp(const char *path, vfs_stat_t *stat, list_t *mtab_list) 44 45 { 45 46 mtab_ent_t *ent; … … 53 54 ent->service_id = stat->service_id; 54 55 55 struct statfsstfs;56 vfs_statfs_t stfs; 56 57 if (vfs_statfs_path(path, &stfs) == EOK) 57 58 str_cpy(ent->fs_name, sizeof(ent->fs_name), stfs.fs_name); … … 74 75 while ((dirent = readdir(dir)) != NULL) { 75 76 char *child; 76 struct stat st;77 vfs_stat_t st; 77 78 errno_t rc; 78 79 int ret; … … 122 123 errno_t vfs_get_mtab_list(list_t *mtab_list) 123 124 { 124 struct stat st;125 vfs_stat_t st; 125 126 126 127 errno_t rc = vfs_stat_path("/", &st); -
uspace/lib/c/generic/vfs/vfs.c
ra0a9cc2 r2b3dd78 352 352 async_sess_t *vfs_fd_session(int file, iface_t iface) 353 353 { 354 struct stat stat;354 vfs_stat_t stat; 355 355 errno_t rc = vfs_stat(file, &stat); 356 356 if (rc != EOK) … … 1052 1052 * @return EOK on success or an error code 1053 1053 */ 1054 errno_t vfs_stat(int file, struct stat *stat)1054 errno_t vfs_stat(int file, vfs_stat_t *stat) 1055 1055 { 1056 1056 errno_t rc; … … 1060 1060 1061 1061 req = async_send_1(exch, VFS_IN_STAT, file, NULL); 1062 rc = async_data_read_start(exch, (void *) stat, sizeof( struct stat));1062 rc = async_data_read_start(exch, (void *) stat, sizeof(vfs_stat_t)); 1063 1063 if (rc != EOK) { 1064 1064 vfs_exchange_end(exch); … … 1086 1086 * @return EOK on success or an error code 1087 1087 */ 1088 errno_t vfs_stat_path(const char *path, struct stat *stat)1088 errno_t vfs_stat_path(const char *path, vfs_stat_t *stat) 1089 1089 { 1090 1090 int file; … … 1107 1107 * @return EOK on success or an error code 1108 1108 */ 1109 errno_t vfs_statfs(int file, struct statfs*st)1109 errno_t vfs_statfs(int file, vfs_statfs_t *st) 1110 1110 { 1111 1111 errno_t rc, ret; … … 1132 1132 * @return EOK on success or an error code 1133 1133 */ 1134 errno_t vfs_statfs_path(const char *path, struct statfs*st)1134 errno_t vfs_statfs_path(const char *path, vfs_statfs_t *st) 1135 1135 { 1136 1136 int file;
Note:
See TracChangeset
for help on using the changeset viewer.