Changeset 8b863a62 in mainline for uspace/lib/posix/source


Ignore:
Timestamp:
2014-04-16T17:14:06Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f857e8b
Parents:
dba3e2c (diff), 70b570c (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:

Merge mainline changes

Location:
uspace/lib/posix/source
Files:
4 added
1 deleted
20 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/source/ctype.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "posix/ctype.h"
  • uspace/lib/posix/source/errno.c

    rdba3e2c r8b863a62  
    3232/** @file System error numbers.
    3333 */
     34#define LIBPOSIX_INTERNAL
     35#define __POSIX_DEF__(x) posix_##x
    3436
    3537#include "posix/errno.h"
     
    4345{
    4446        if (*__errno() != 0) {
    45                 _posix_errno = abs(*__errno());
     47                _posix_errno = posix_abs(*__errno());
    4648                *__errno() = 0;
    4749        }
  • uspace/lib/posix/source/fcntl.c

    rdba3e2c r8b863a62  
    3434
    3535#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3637
    3738#include "internal/common.h"
  • uspace/lib/posix/source/fnmatch.c

    rdba3e2c r8b863a62  
    4343
    4444#define LIBPOSIX_INTERNAL
     45#define __POSIX_DEF__(x) posix_##x
    4546
    4647#include "libc/stdbool.h"
  • uspace/lib/posix/source/getopt.c

    rdba3e2c r8b863a62  
    3333 */
    3434#define LIBPOSIX_INTERNAL
     35#define __POSIX_DEF__(x) posix_##x
    3536
    3637#include "internal/common.h"
  • uspace/lib/posix/source/internal/common.h

    rdba3e2c r8b863a62  
    3939#include <stdlib.h>
    4040
    41 #define not_implemented() (fprintf(stderr, \
    42     "Function %s() in file %s at line %d is not implemented\n", \
    43     __func__, __FILE__, __LINE__), abort())
     41#define not_implemented() do { \
     42                static int __not_implemented_counter = 0; \
     43                if (__not_implemented_counter == 0) { \
     44                        fprintf(stderr, "%s() not implemented in %s:%d, something will NOT work.\n", \
     45                                __func__, __FILE__, __LINE__); \
     46                } \
     47                __not_implemented_counter++; \
     48        } while (0)
    4449
    4550/* A little helper macro to avoid typing this over and over. */
  • uspace/lib/posix/source/locale.c

    rdba3e2c r8b863a62  
    3434
    3535#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3637
    3738#include "internal/common.h"
  • uspace/lib/posix/source/pwd.c

    rdba3e2c r8b863a62  
    3434
    3535#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3637
    3738#include "libc/stdbool.h"
  • uspace/lib/posix/source/signal.c

    rdba3e2c r8b863a62  
    3434
    3535#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3637
    3738#include "posix/signal.h"
  • uspace/lib/posix/source/stdio.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "internal/common.h"
     
    308309}
    309310
    310 struct _posix_fpos {
    311         off64_t offset;
    312 };
    313 
    314311/** Restores stream a to position previously saved with fgetpos().
    315312 *
  • uspace/lib/posix/source/stdio/scanf.c

    rdba3e2c r8b863a62  
    3434
    3535#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3637
    3738#include "posix/assert.h"
  • uspace/lib/posix/source/stdlib.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "internal/common.h"
     
    6263        // TODO: low priority, just a compile-time dependency of binutils
    6364        not_implemented();
     65        return 0;
    6466}
    6567
     
    231233        // TODO: low priority, just a compile-time dependency of binutils
    232234        not_implemented();
     235        return 0;
    233236}
    234237
     
    243246int posix_system(const char *string) {
    244247        // TODO: does nothing at the moment
     248        not_implemented();
    245249        return 0;
    246250}
     
    387391                free(ptr);
    388392        }
     393}
     394
     395/**
     396 * Generate a pseudo random integer in the range 0 to RAND_MAX inclusive.
     397 *
     398 * @return The pseudo random integer.
     399 */
     400int posix_rand(void)
     401{
     402        return (int) random();
     403}
     404
     405/**
     406 * Initialize a new sequence of pseudo-random integers.
     407 *
     408 * @param seed The seed of the new sequence.
     409 */
     410void posix_srand(unsigned int seed)
     411{
     412        srandom(seed);
    389413}
    390414
  • uspace/lib/posix/source/stdlib/strtol.c

    rdba3e2c r8b863a62  
    3434
    3535#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3637
    3738#include "../internal/common.h"
  • uspace/lib/posix/source/stdlib/strtold.c

    rdba3e2c r8b863a62  
    3434
    3535#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3637
    3738#include "../internal/common.h"
  • uspace/lib/posix/source/string.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "internal/common.h"
  • uspace/lib/posix/source/strings.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "internal/common.h"
  • uspace/lib/posix/source/sys/mman.c

    rdba3e2c r8b863a62  
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup libposix
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include <sys/mman.h>
    36 #include <sys/types.h>
    37 #include <as.h>
    38 #include <unistd.h>
     35#define LIBPOSIX_INTERNAL
     36#define __POSIX_DEF__(x) posix_##x
    3937
    40 void *mmap(void *start, size_t length, int prot, int flags, int fd,
    41     aoff64_t offset)
     38#include "../internal/common.h"
     39#include <posix/sys/mman.h>
     40#include <posix/sys/types.h>
     41#include <libc/as.h>
     42#include <posix/unistd.h>
     43
     44void *posix_mmap(void *start, size_t length, int prot, int flags, int fd,
     45    __POSIX_DEF__(off_t) offset)
    4246{
    4347        if (!start)
     
    5357}
    5458
    55 int munmap(void *start, size_t length)
     59int posix_munmap(void *start, size_t length)
    5660{
    5761        return as_area_destroy(start);
  • uspace/lib/posix/source/sys/stat.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "../internal/common.h"
  • uspace/lib/posix/source/sys/wait.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "../internal/common.h"
  • uspace/lib/posix/source/time.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "internal/common.h"
     
    7374        posix_daylight = 0;
    7475        posix_timezone = 0;
     76}
     77
     78/**
     79 * Get the time in seconds
     80 *
     81 * @param t If t is non-NULL, the return value is also stored in the memory
     82 *          pointed to by t.
     83 * @return  On success, the value of time in seconds since the Epoch
     84 *          is returned. On error, (time_t)-1 is returned.
     85 */
     86time_t posix_time(time_t *t)
     87{
     88        return time(t);
    7589}
    7690
  • uspace/lib/posix/source/unistd.c

    rdba3e2c r8b863a62  
    3535
    3636#define LIBPOSIX_INTERNAL
     37#define __POSIX_DEF__(x) posix_##x
    3738
    3839#include "internal/common.h"
     
    220221{
    221222        return errnify(write, fildes, buf, nbyte);
     223}
     224
     225/**
     226 * Reposition read/write file offset
     227 *
     228 * @param fildes File descriptor of the opened file.
     229 * @param offset New offset in the file.
     230 * @param whence The position from which the offset argument is specified.
     231 * @return Upon successful completion, returns the resulting offset
     232 *         as measured in bytes from the beginning of the file, -1 otherwise.
     233 */
     234posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence)
     235{
     236        return errnify(lseek, fildes, offset, whence);
    222237}
    223238
     
    374389        // TODO: low priority, just a compile-time dependency of binutils
    375390        not_implemented();
     391        return -1;
    376392}
    377393
     
    384400        // TODO: low priority, just a compile-time dependency of binutils
    385401        not_implemented();
     402        return -1;
    386403}
    387404
     
    396413        // TODO: low priority, just a compile-time dependency of binutils
    397414        not_implemented();
     415        return -1;
    398416}
    399417
     
    408426        // TODO: low priority, just a compile-time dependency of binutils
    409427        not_implemented();
     428        return -1;
    410429}
    411430
     
    419438        // TODO: low priority, just a compile-time dependency of binutils
    420439        not_implemented();
     440        return -1;
     441}
     442
     443unsigned int posix_alarm(unsigned int seconds)
     444{
     445        not_implemented();
     446        return 0;
    421447}
    422448
Note: See TracChangeset for help on using the changeset viewer.