[haiku-commits] BRANCH mmadia-github.separate-build-environment - in headers/build/posix_target: . headers/build

  • From: mmadia-github.separate-build-environment <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 10 Aug 2012 17:49:19 +0200 (CEST)

added 3 changesets to branch 
'refs/remotes/mmadia-github/separate-build-environment'
old head: 695b8cd2477f0c89fd3703001026a73b93fd817f
new head: 26852663eef26cbabc588092bc639f5f7a4f5202

----------------------------------------------------------------------------

d6cdc49: Create _HAIKU_BUILD_DECLARE_FUNCTION_ETC macro.

ed82f64: Added to the TODO for _HAIKU_BUILD_FEATURE_wchar_t

2685266: First pass at adding target_stdio*.h
  
  Notes and TODO's included.  Review more than appreciated.

                                        [ Matt Madia <mattmadia@xxxxxxxxx> ]

----------------------------------------------------------------------------

7 files changed, 310 insertions(+), 1 deletion(-)
headers/build/HaikuBuild.h                     |    6 +
headers/build/posix_target/target_libio.h      |    8 +
headers/build/posix_target/target_stdio.h      |  266 ++++++++++++++++++++
headers/build/posix_target/target_stdio_ext.h  |    8 +
headers/build/posix_target/target_stdio_post.h |    8 +
headers/build/posix_target/target_stdio_pre.h  |    8 +
headers/build/posix_target/target_stdlib.h     |    7 +-

############################################################################

Commit:      d6cdc49fba4baf217e872945f0b446db953fa218

Author:      Matt Madia <mattmadia@xxxxxxxxx>
Date:        Fri Aug 10 14:21:20 2012 UTC

Create _HAIKU_BUILD_DECLARE_FUNCTION_ETC macro.

----------------------------------------------------------------------------

diff --git a/headers/build/HaikuBuild.h b/headers/build/HaikuBuild.h
index cef8d15..0db0cc2 100644
--- a/headers/build/HaikuBuild.h
+++ b/headers/build/HaikuBuild.h
@@ -17,6 +17,8 @@
 #ifdef _HAIKU_BUILD_LIBROOT_FUNCTION_WRAPPER
 #      define _HAIKU_BUILD_DECLARE_FUNCTION(returnValue, name, parameters)     
\
                returnValue _haiku_build_##name parameters;
+#      define _HAIKU_BUILD_DECLARE_FUNCTION_ETC(returnValue, name, parameters, 
etc)    \
+               returnValue _haiku_build_##name parameters etc;
 #      define _HAIKU_BUILD_DECLARE_VARIABLE(type, name) \
                extern type _haiku_build_##name;
 #      define _HAIKU_BUILD_DECLARE_VARIABLE_ETC(type, name, etc) \
@@ -27,6 +29,10 @@
                returnValue _haiku_build_##name parameters;                     
                        \
                returnValue name parameters                                     
                                        \
                        __asm__(_HAIKU_BUILD_ASMNAME("_haiku_build_" #name));
+#      define _HAIKU_BUILD_DECLARE_FUNCTION_ETC(returnValue, name, parameters, 
etc)    \
+               returnValue _haiku_build_##name parameters etc;                 
                        \
+               returnValue name parameters     etc                             
                                        \
+                       __asm__(_HAIKU_BUILD_ASMNAME("_haiku_build_" #name));
 #      define _HAIKU_BUILD_DECLARE_VARIABLE(type, name) \
                extern type _haiku_build_##name; \
                extern type name \

############################################################################

Commit:      ed82f648774a68adb796f7ddf1e9a367e68b5815

Author:      Matt Madia <mattmadia@xxxxxxxxx>
Date:        Fri Aug 10 14:21:49 2012 UTC

Added to the TODO for _HAIKU_BUILD_FEATURE_wchar_t

----------------------------------------------------------------------------

diff --git a/headers/build/posix_target/target_stdlib.h 
b/headers/build/posix_target/target_stdlib.h
index 63ef846..3538eda 100644
--- a/headers/build/posix_target/target_stdlib.h
+++ b/headers/build/posix_target/target_stdlib.h
@@ -195,7 +195,12 @@ 
_HAIKU_BUILD_DECLARE_FUNCTION(_HAIKU_BUILD_IDENTIFIER(lldiv_t), lldiv,
 
 /* wide & multibyte string functions */
 _HAIKU_BUILD_DECLARE_FUNCTION(int, mblen, (const char *string, size_t maxSize))
-// TODO: #8730 -- which _HAIKU_BUILD_FEATURE_* for wchar_t?
+/* TODO: #8730 -- _HAIKU_BUILD_FEATURE_* for wchar_t
+       You'll need to add a new one just like for the fixed width integer 
types,
+       i.e. just add a "PRINT_TYPE_INFO(wchar);" in test_int_types.cpp. 
Unless, of
+       course, <wchar_t.h> isn't wrapped by FreeBSD. Then you can include it 
and
+       use wchar_t directly.
+*/
 _HAIKU_BUILD_DECLARE_FUNCTION(int, mbtowc, (wchar_t *pwc,
        const char *string, size_t maxSize))
 _HAIKU_BUILD_DECLARE_FUNCTION(int, wctomb, (char *string, wchar_t wchar))

############################################################################

Commit:      26852663eef26cbabc588092bc639f5f7a4f5202

Author:      Matt Madia <mattmadia@xxxxxxxxx>
Date:        Fri Aug 10 15:26:56 2012 UTC

First pass at adding target_stdio*.h

Notes and TODO's included.  Review more than appreciated.

----------------------------------------------------------------------------

diff --git a/headers/build/posix_target/target_libio.h 
b/headers/build/posix_target/target_libio.h
new file mode 100644
index 0000000..c806a49
--- /dev/null
+++ b/headers/build/posix_target/target_libio.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2012 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _IO_STDIO_H_
+#define _IO_STDIO_H_
+
+#endif
diff --git a/headers/build/posix_target/target_stdio.h 
b/headers/build/posix_target/target_stdio.h
new file mode 100644
index 0000000..e8594b8
--- /dev/null
+++ b/headers/build/posix_target/target_stdio.h
@@ -0,0 +1,266 @@
+/*
+ * Copyright 2004-2012 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+
+#include <sys/target_types.h>
+#include <target_null.h>
+#include <target_stdarg.h>
+
+
+/* Dodge gcc 2.95.3's fixincludes hack stdio_va_list by including this string:
+ * __gnuc_va_list */
+
+
+#define _HAIKU_BUILD_BUFSIZ                    8192
+#define _HAIKU_BUILD_IOFBF                     0               /* fully 
buffered */
+#define _HAIKU_BUILD_IOLBF                     1               /* line 
buffered */
+#define _HAIKU_BUILD_IONBF                     2               /* not buffered 
*/
+
+/*
+ * FOPEN_MAX is a minimum maximum, and should be the number of descriptors
+ * that the kernel can provide without allocation of a resource that can
+ * fail without the process sleeping.  Do not use this for anything
+ */
+#define _HAIKU_BUILD_FOPEN_MAX         128
+#define _HAIKU_BUILD_STREAM_MAX                _HAIKU_BUILD_FOPEN_MAX
+#define _HAIKU_BUILD_FILENAME_MAX      256
+#define _HAIKU_BUILD_TMP_MAX           32768
+
+#define _HAIKU_BUILD_L_ctermid         32
+#define _HAIKU_BUILD_L_cuserid         32
+#define _HAIKU_BUILD_L_tmpnam          512
+
+#define _HAIKU_BUILD_P_tmpdir          "/tmp/"
+
+#ifdef _HAIKU_BUILD_EOF
+#      undef _HAIKU_BUILD_EOF
+#endif
+#define _HAIKU_BUILD_EOF                       -1
+
+#ifndef _HAIKU_BUILD_SEEK_SET
+#      define _HAIKU_BUILD_SEEK_SET    0
+#endif
+#ifndef _HAIKU_BUILD_SEEK_CUR
+#      define _HAIKU_BUILD_SEEK_CUR    1
+#endif
+#ifndef _HAIKU_BUILD_SEEK_END
+#      define _HAIKU_BUILD_SEEK_END    2
+#endif
+
+
+typedef _haiku_build_off_t fpos_t;
+
+#ifndef _HAIKU_BUILD_LIBROOT_FUNCTION_WRAPPER
+#      define BUFSIZ                   _HAIKU_BUILD_BUFSIZ
+#      define _IOFBF                   _HAIKU_BUILD_IOFBF              /* 
fully buffered */
+#      define _IOLBF                   _HAIKU_BUILD_IOLBF              /* line 
buffered */
+#      define _IONBF                   _HAIKU_BUILD_IONBF              /* not 
buffered */
+
+/*
+ * FOPEN_MAX is a minimum maximum, and should be the number of descriptors
+ * that the kernel can provide without allocation of a resource that can
+ * fail without the process sleeping.  Do not use this for anything
+ */
+#      define FOPEN_MAX                _HAIKU_BUILD_FOPEN_MAX
+#      define STREAM_MAX               _HAIKU_BUILD_STREAM_MAX
+#      define FILENAME_MAX             _HAIKU_BUILD_FILENAME_MAX
+#      define TMP_MAX                  _HAIKU_BUILD_TMP_MAX
+
+#      define L_ctermid                _HAIKU_BUILD_L_ctermid
+#      define L_cuserid                _HAIKU_BUILD_L_cuserid
+#      define L_tmpnam                 _HAIKU_BUILD_L_tmpnam
+
+#      define  P_tmpdir                _HAIKU_BUILD_P_tmpdir
+
+#      ifdef EOF
+#              undef EOF
+#      endif
+#      define EOF                              _HAIKU_BUILD_EOF
+
+#      ifndef SEEK_SET
+#              define SEEK_SET         _HAIKU_BUILD_SEEK_SET
+#      endif
+#      ifndef SEEK_CUR
+#              define SEEK_CUR         _HAIKU_BUILD_SEEK_CUR
+#      endif
+#      ifndef SEEK_END
+#              define SEEK_END         _HAIKU_BUILD_SEEK_END
+#      endif
+
+
+typedef _haiku_build_off_t     fpos_t;
+#      endif   /* _STDIO_H_ */
+
+/* TODO: #8730 -- stdio_pre.h, stdio_post.h, etc.
+       The stdio_pre.h and stdio_post.h headers are implementation details. 
They
+       are never included by client code. Their contents should be revised and
+       merged into stdio.h.
+
+       FILE should by defined as an opaque type, fgetc() and fputc() should be
+       defined as function prototypes, not macros or inline functions.
+
+       stdio_ext.h may not be needed either.
+       Start with an empty file and only add something, if actually used.
+*/
+//#include <target_stdio_pre.h>
+typedef struct _HAIKU_BUILD_IDENTIFIER(_IO_FILE) FILE;
+
+#define __HAIKU_BUILD_PRINTFLIKE(format, varargs) __attribute__ ((__format__ 
(__printf__, format, varargs)))
+#define __HAIKU_BUILD_SCANFLIKE(format, varargs) __attribute__((__format__ 
(__scanf__, format, varargs)))
+#ifndef _HAIKU_BUILD_LIBROOT_FUNCTION_WRAPPER
+#      define __PRINTFLIKE(format, varargs)    
__HAIKU_BUILD_PRINTFLIKE(format, varargs)
+#      define __SCANFLIKE(format, varargs)             
__HAIKU_BUILD_SCANFLIKE(format, varargs)
+#endif /* _HAIKU_BUILD_LIBROOT_FUNCTION_WRAPPER */
+// end of stdio_pre.h
+
+_HAIKU_BUILD_DECLARE_VARIABLE(FILE*, stdin)
+_HAIKU_BUILD_DECLARE_VARIABLE(FILE*, stdout)
+_HAIKU_BUILD_DECLARE_VARIABLE(FILE*, stderr)
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* file operations */
+_HAIKU_BUILD_DECLARE_FUNCTION(FILE*, fopen, (const char *name, const char 
*mode))
+_HAIKU_BUILD_DECLARE_FUNCTION(FILE*, freopen, (const char *name, const char 
*mode, FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(FILE*, fdopen, (int fd, const char *mode))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fclose, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fileno, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fileno_unlocked, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, ferror, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, ferror_unlocked, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(void, clearerr, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(void, clearerr_unlocked, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, feof, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, feof_unlocked, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(void, flockfile, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(void, funlockfile, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, ftrylockfile, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, remove, (const char *name))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, rename, (const char *from, const char *to))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, renameat, (int fromFD, const char *from, 
int toFD, const char *to))
+
+/* pipes */
+_HAIKU_BUILD_DECLARE_FUNCTION(FILE*, popen, (const char *command, const char 
*mode))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, pclose, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(void, perror, (const char *errorPrefix))
+
+/* memory streams */
+_HAIKU_BUILD_DECLARE_FUNCTION(FILE*, fmemopen, (void *buf, size_t size, const 
char *mode))
+_HAIKU_BUILD_DECLARE_FUNCTION(FILE*, open_memstream, (char **buf, size_t 
*size))
+
+/* file I/O */
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fflush, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fflush_unlocked, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fpurge, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fgetpos, (FILE *stream, fpos_t *position))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fsetpos, (FILE *stream, const fpos_t 
*position))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fseek, (FILE *stream, long offset, int 
seekType))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fseeko, (FILE *stream, off_t offset, int 
seekType))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, _fseek, (FILE *stream, fpos_t offset, int 
seekType))
+_HAIKU_BUILD_DECLARE_FUNCTION(long, ftell, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(_haiku_build_off_t, ftello, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(_haiku_build_fpos_t, _ftell, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(void, rewind, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(void, setbuf, (FILE *file, char *buff))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, setvbuf, (FILE *file, char *buff, int mode, 
size_t size))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, setbuffer, (FILE *stream, char *buf, size_t 
size))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, setlinebuf, (FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(size_t, fwrite, (const void *buffer, size_t 
size, size_t numItems, FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(size_t, fread, (void *buffer, size_t size, 
size_t numItems, FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, putc, (int c, FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, putchar(int c))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, putc_unlocked, (int c, FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, putchar_unlocked, (int c))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fputc, (int c, FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fputc_unlocked, (int c, FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, puts, (const char *string))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fputs, (const char *string, FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, getc, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, getc_unlocked, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, ungetc, (int c, FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, getchar, (void))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, getchar_unlocked, (void))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fgetc, (FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(char*, gets, (char *buffer))
+_HAIKU_BUILD_DECLARE_FUNCTION(char*, fgets, (char *string, int stringLength, 
FILE *stream))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(ssize_t, getdelim, (char **_line, size_t 
*_length, int delimiter,
+                                       FILE *stream))
+_HAIKU_BUILD_DECLARE_FUNCTION(ssize_t, getline, (char **_line, size_t 
*_length, FILE *stream))
+
+/* formatted I/O */
+/* TODO: #8730 */
+_HAIKU_BUILD_DECLARE_FUNCTION_ETC(int, printf, (char const *format, ...), 
__PRINTFLIKE(1,2))
+_HAIKU_BUILD_DECLARE_FUNCTION_ETC(int, fprintf, (FILE *stream, char const 
*format, ...), __PRINTFLIKE(2,3))
+_HAIKU_BUILD_DECLARE_FUNCTION_ETC(int, sprintf, (char *string, char const 
*format, ...), __PRINTFLIKE(2,3))
+_HAIKU_BUILD_DECLARE_FUNCTION_ETC(int, snprintf, (char *string, size_t size, 
char const *format, ...), __PRINTFLIKE(3,4))
+_HAIKU_BUILD_DECLARE_FUNCTION_ETC(int, asprintf, (char **ret, char const 
*format, ...), __PRINTFLIKE(2,3))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vprintf, (char const *format, va_list ap))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vfprintf, (FILE *stream, char const 
*format, va_list ap))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vsprintf, (char *string, char const 
*format, va_list ap))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vsnprintf, (char *string, size_t size, char 
const *format, va_list ap))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vasprintf, (char **ret, char const *format, 
va_list ap))
+
+_HAIKU_BUILD_DECLARE_FUNCTION(int, scanf, (char const *format, ...))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, fscanf, (FILE *stream, char const *format, 
...))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, sscanf, (char const *str, char const 
*format, ...))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vscanf, (char const *format, va_list ap))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vsscanf, (char const *str, char const 
*format, va_list ap))
+_HAIKU_BUILD_DECLARE_FUNCTION(int, vfscanf, (FILE *stream, char const *format, 
va_list ap))
+
+/* misc */
+_HAIKU_BUILD_DECLARE_FUNCTION(char*, ctermid, (char *controllingTerminal))
+_HAIKU_BUILD_DECLARE_FUNCTION(char*, cuserid, (char *s))
+
+/* temporary files */
+_HAIKU_BUILD_DECLARE_FUNCTION(char*, tempnam, (char const *path, char const 
*prefix))
+_HAIKU_BUILD_DECLARE_FUNCTION(FILE*, tmpfile,(void))
+_HAIKU_BUILD_DECLARE_FUNCTION(char*, tmpnam,(char *nameBuffer))
+_HAIKU_BUILD_DECLARE_FUNCTION(char*, tmpnam_r, (char *nameBuffer))
+
+// #include <target_stdio_post.h>
+// NOTE: #8730 -- uncertain on these changes pertaining to including 
stdio_post.h
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_HAIKU_BUILD_DECLARE_VARIABLE(char, _single_threaded)
+       /* this boolean value is true (1) if there is only the main thread
+        * running - as soon as you spawn the first thread, it's set to
+        * false (0) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#define _haiku_build_getc(stream) \
+       (_single_threaded ? _haiku_build_getc_unlocked(stream) : 
_haiku_build_getc(stream))
+#define _haiku_build_putc(c, stream) \
+       (_single_threaded ? _haiku_build_putc_unlocked(c, stream) : 
_haiku_build_putc(c, stream))
+
+// end of stdio_post.h
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _STDIO_H_ */
diff --git a/headers/build/posix_target/target_stdio_ext.h 
b/headers/build/posix_target/target_stdio_ext.h
new file mode 100644
index 0000000..d2a83e4
--- /dev/null
+++ b/headers/build/posix_target/target_stdio_ext.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2012 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _STDIO_EXT_H_
+#define _STDIO_EXT_H_
+
+#endif
diff --git a/headers/build/posix_target/target_stdio_post.h 
b/headers/build/posix_target/target_stdio_post.h
new file mode 100644
index 0000000..df18f02
--- /dev/null
+++ b/headers/build/posix_target/target_stdio_post.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2012 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _STDIO_POST_H_
+#define _STDIO_POST_H_
+
+#endif
diff --git a/headers/build/posix_target/target_stdio_pre.h 
b/headers/build/posix_target/target_stdio_pre.h
new file mode 100644
index 0000000..9a57845
--- /dev/null
+++ b/headers/build/posix_target/target_stdio_pre.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright 2012 Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _STDIO_PRE_H_
+#define _STDIO_PRE_H_
+
+#endif
\ No newline at end of file


Other related posts: