Ignore:
Timestamp:
2013-07-10T08:58:49Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3908355, 4c53333
Parents:
30c1b75 (diff), 98abd40 (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:

Extending POSIX library

Merge from lp:~vojtech-horky/helenos/gcc-port.

This is work-in-progress merge from branch aimed at bringing GCC to run
inside HelenOS.

The most notable change is dealing with the name clashes in libposix and
libc. For ported applications, the libposix headers looks as normal
POSIX headers and there is no need to do preprocessor-based renaming inside
the ported application. The renaming is done inside object files instead.
See revision 1745 in lp:~vojtech-horky/helenos/gcc-port [1] for more
detailed explanation.
The solution is definitely not perfect but shall deal with the naming
conflicts in much safer manner than using the redefines.

There were some other changes as well, mostly small ones.

  • Add some functions, some as ToDo ones (i.e. empty implementation).
  • Add more POSIX headers, split some existing.

[1] http://bazaar.launchpad.net/~vojtech-horky/helenos/gcc-port/revision/1745

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/include/posix/stdlib.h

    r30c1b75 rc8bb1633  
    3737#define POSIX_STDLIB_H_
    3838
     39#ifndef __POSIX_DEF__
     40#define __POSIX_DEF__(x) x
     41#endif
     42
    3943#include "sys/types.h"
    4044
     
    4953#define EXIT_SUCCESS 0
    5054#define _Exit exit
    51 extern int posix_atexit(void (*func)(void));
     55extern int __POSIX_DEF__(atexit)(void (*func)(void));
    5256extern void exit(int status);
    5357extern void abort(void) __attribute__((noreturn));
    5458
    5559/* Absolute Value */
    56 extern int posix_abs(int i);
    57 extern long posix_labs(long i);
    58 extern long long posix_llabs(long long i);
     60extern int __POSIX_DEF__(abs)(int i);
     61extern long __POSIX_DEF__(labs)(long i);
     62extern long long __POSIX_DEF__(llabs)(long long i);
    5963
    6064/* Integer Division */
     
    6266typedef struct {
    6367        int quot, rem;
    64 } posix_div_t;
     68} __POSIX_DEF__(div_t);
    6569
    6670typedef struct {
    6771        long quot, rem;
    68 } posix_ldiv_t;
     72} __POSIX_DEF__(ldiv_t);
    6973
    7074typedef struct {
    7175        long long quot, rem;
    72 } posix_lldiv_t;
     76} __POSIX_DEF__(lldiv_t);
    7377
    74 extern posix_div_t posix_div(int numer, int denom);
    75 extern posix_ldiv_t posix_ldiv(long numer, long denom);
    76 extern posix_lldiv_t posix_lldiv(long long numer, long long denom);
     78extern __POSIX_DEF__(div_t) __POSIX_DEF__(div)(int numer, int denom);
     79extern __POSIX_DEF__(ldiv_t) __POSIX_DEF__(ldiv)(long numer, long denom);
     80extern __POSIX_DEF__(lldiv_t) __POSIX_DEF__(lldiv)(long long numer, long long denom);
    7781
    7882/* Array Functions */
    79 extern void posix_qsort(void *array, size_t count, size_t size,
     83extern void __POSIX_DEF__(qsort)(void *array, size_t count, size_t size,
    8084    int (*compare)(const void *, const void *));
    81 extern void *posix_bsearch(const void *key, const void *base,
     85extern void *__POSIX_DEF__(bsearch)(const void *key, const void *base,
    8286    size_t nmemb, size_t size, int (*compar)(const void *, const void *));
    8387
    8488/* Environment Access */
    85 extern char *posix_getenv(const char *name);
    86 extern int posix_putenv(char *string);
    87 extern int posix_system(const char *string);
     89extern char *__POSIX_DEF__(getenv)(const char *name);
     90extern int __POSIX_DEF__(putenv)(char *string);
     91extern int __POSIX_DEF__(system)(const char *string);
    8892
    8993/* Symbolic Links */
    90 extern char *posix_realpath(const char *restrict name, char *restrict resolved);
     94extern char *__POSIX_DEF__(realpath)(const char *restrict name, char *restrict resolved);
    9195
    9296/* Floating Point Conversion */
    93 extern double posix_atof(const char *nptr);
    94 extern float posix_strtof(const char *restrict nptr, char **restrict endptr);
    95 extern double posix_strtod(const char *restrict nptr, char **restrict endptr);
    96 extern long double posix_strtold(const char *restrict nptr, char **restrict endptr);
     97extern double __POSIX_DEF__(atof)(const char *nptr);
     98extern float __POSIX_DEF__(strtof)(const char *restrict nptr, char **restrict endptr);
     99extern double __POSIX_DEF__(strtod)(const char *restrict nptr, char **restrict endptr);
     100extern long double __POSIX_DEF__(strtold)(const char *restrict nptr, char **restrict endptr);
    97101
    98102/* Integer Conversion */
    99 extern int posix_atoi(const char *nptr);
    100 extern long int posix_atol(const char *nptr);
    101 extern long long int posix_atoll(const char *nptr);
    102 extern long int posix_strtol(const char *restrict nptr,
     103extern int __POSIX_DEF__(atoi)(const char *nptr);
     104extern long int __POSIX_DEF__(atol)(const char *nptr);
     105extern long long int __POSIX_DEF__(atoll)(const char *nptr);
     106extern long int __POSIX_DEF__(strtol)(const char *restrict nptr,
    103107    char **restrict endptr, int base);
    104 extern long long int posix_strtoll(const char *restrict nptr,
     108extern long long int __POSIX_DEF__(strtoll)(const char *restrict nptr,
    105109    char **restrict endptr, int base);
    106 extern unsigned long int posix_strtoul(const char *restrict nptr,
     110extern unsigned long int __POSIX_DEF__(strtoul)(const char *restrict nptr,
    107111    char **restrict endptr, int base);
    108 extern unsigned long long int posix_strtoull(
     112extern unsigned long long int __POSIX_DEF__(strtoull)(
    109113    const char *restrict nptr, char **restrict endptr, int base);
    110114
    111115/* Memory Allocation */
    112 extern void *posix_malloc(size_t size);
    113 extern void *posix_calloc(size_t nelem, size_t elsize);
    114 extern void *posix_realloc(void *ptr, size_t size);
    115 extern void posix_free(void *ptr);
     116extern void *__POSIX_DEF__(malloc)(size_t size);
     117extern void *__POSIX_DEF__(calloc)(size_t nelem, size_t elsize);
     118extern void *__POSIX_DEF__(realloc)(void *ptr, size_t size);
     119extern void __POSIX_DEF__(free)(void *ptr);
    116120
    117121/* Temporary Files */
    118 extern int posix_mkstemp(char *tmpl);
     122extern int __POSIX_DEF__(mkstemp)(char *tmpl);
    119123
    120124/* Legacy Declarations */
    121 extern char *posix_mktemp(char *tmpl);
     125extern char *__POSIX_DEF__(mktemp)(char *tmpl);
    122126extern int bsd_getloadavg(double loadavg[], int nelem);
    123 
    124 #ifndef LIBPOSIX_INTERNAL
    125         #define atexit posix_atexit
    126 
    127         #define abs posix_abs
    128         #define labs posix_labs
    129         #define llabs posix_llabs
    130 
    131         #define div_t posix_div_t
    132         #define ldiv_t posix_ldiv_t
    133         #define lldiv_t posix_lldiv_t
    134         #define div posix_div
    135         #define ldiv posix_ldiv
    136         #define lldiv posix_lldiv
    137 
    138         #define qsort posix_qsort
    139         #define bsearch posix_bsearch
    140 
    141         #define getenv posix_getenv
    142         #define putenv posix_putenv
    143         #define system posix_system
    144 
    145         #define realpath posix_realpath
    146        
    147         #define atof posix_atof
    148         #define strtof posix_strtof
    149         #define strtod posix_strtod
    150         #define strtold posix_strtold
    151        
    152         #define atoi posix_atoi
    153         #define atol posix_atol
    154         #define atoll posix_atoll
    155         #define strtol posix_strtol
    156         #define strtoll posix_strtoll
    157         #define strtoul posix_strtoul
    158         #define strtoull posix_strtoull
    159 
    160         #define malloc posix_malloc
    161         #define calloc posix_calloc
    162         #define realloc posix_realloc
    163         #define free posix_free
    164 
    165         #define mkstemp posix_mkstemp
    166 
    167         #define mktemp posix_mktemp
    168         #define getloadavg bsd_getloadavg
    169 #endif
    170127
    171128#endif  // POSIX_STDLIB_H_
Note: See TracChangeset for help on using the changeset viewer.