[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH 1/2] libc: extern "C" in Headerdateien
* libc: Headerdateien fuer C++ brauchbar machen
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
src/include/setjmp.h | 9 +++++++++
src/include/stdlib.h | 8 ++++++++
src/include/string.h | 9 +++++++++
src/modules/include/arpa/inet.h | 9 +++++++++
src/modules/include/assert.h | 9 +++++++++
src/modules/include/math.h | 8 ++++++++
src/modules/include/netdb.h | 8 ++++++++
src/modules/include/signal.h | 9 +++++++--
src/modules/include/stdio.h | 7 +++++++
src/modules/include/sys/socket.h | 9 +++++++++
src/modules/include/time.h | 8 ++++++++
src/modules/include/unistd.h | 9 +++++++++
12 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/src/include/setjmp.h b/src/include/setjmp.h
index 18f91e5..bc47809 100644
--- a/src/include/setjmp.h
+++ b/src/include/setjmp.h
@@ -32,7 +32,16 @@
typedef uintptr_t jmp_buf[9];
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int setjmp(jmp_buf env);
void longjmp(jmp_buf env, int value);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/include/stdlib.h b/src/include/stdlib.h
index 8475e46..d56d879 100644
--- a/src/include/stdlib.h
+++ b/src/include/stdlib.h
@@ -40,6 +40,10 @@
/** Maximale laenge eines Multibyte-Zeichens in Bytes */
#define MB_CUR_MAX 4
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void exit(int result);
void abort(void);
int atexit(void (*function)(void));
@@ -254,4 +258,8 @@ char* mktemp(char* _template);
/// Temporaere Datei anlegen
int mkstemp(char* _template);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/include/string.h b/src/include/string.h
index e530689..5f71088 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -28,8 +28,13 @@
#ifndef _STRING_H_
#define _STRING_H_
+
#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void* memcpy(void* dest, const void* src, size_t num);
void* memccpy(void* dest, const void* src, int c, size_t num);
void* memmove(void* dest, const void* src, size_t num);
@@ -82,5 +87,9 @@ int strncasecmp(const char* s1, const char* s2, size_t n);
int strcoll(const char* s1, const char* s2);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif /* ndef _STRING_H */
diff --git a/src/modules/include/arpa/inet.h b/src/modules/include/arpa/inet.h
index 8224bf0..4689df6 100644
--- a/src/modules/include/arpa/inet.h
+++ b/src/modules/include/arpa/inet.h
@@ -31,6 +31,11 @@
#include <netinet/in.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
unsigned long int htonl(unsigned long int hostlong);
unsigned short int htons(unsigned short int hostshort);
unsigned long int ntohl(unsigned long int netlong);
@@ -78,5 +83,9 @@ int inet_pton(int family, const char* src, void* dst);
*/
const char *inet_ntop(int family, const void* src, char* dst, socklen_t size);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/modules/include/assert.h b/src/modules/include/assert.h
index 3ed64f6..87acd4e 100644
--- a/src/modules/include/assert.h
+++ b/src/modules/include/assert.h
@@ -31,6 +31,10 @@
#undef assert
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifdef NDEBUG
#define assert(x) ((void) 0)
#else
@@ -39,5 +43,10 @@ void _assert(const char* assertion, const char* file, int line,
// Das #x verwandelt x in einen String
#define assert(x) _assert(#x, __FILE__, __LINE__, !!(x))
+
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/modules/include/math.h b/src/modules/include/math.h
index 486e21e..207fd3d 100644
--- a/src/modules/include/math.h
+++ b/src/modules/include/math.h
@@ -50,6 +50,10 @@
#define M_SQRT1_2 0.70710678118654752440
+#ifdef __cplusplus
+extern "C" {
+#endif
+
double tan(double);
float tanf(float);
long double tanl(long double);
@@ -113,5 +117,9 @@ long double nearbyintl(long double x);
double rint(double x);
double pow(double x, double y);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/modules/include/netdb.h b/src/modules/include/netdb.h
index feb0ba2..f65c5f0 100644
--- a/src/modules/include/netdb.h
+++ b/src/modules/include/netdb.h
@@ -55,6 +55,11 @@ struct protoent {
int p_proto;
};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct hostent* gethostbyname(const char* name);
/**
@@ -97,6 +102,9 @@ const char* hstrerror(int error);
*/
void herror(const char* str);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
#endif
diff --git a/src/modules/include/signal.h b/src/modules/include/signal.h
index 4c6f9de..4f5ebd7 100644
--- a/src/modules/include/signal.h
+++ b/src/modules/include/signal.h
@@ -109,6 +109,10 @@ typedef uint32_t sig_atomic_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
// Gehoert nach Spezifikation da nicht rein.
void _signal_default_handler(int signal);
@@ -209,8 +213,9 @@ int raise(int signal);
int kill(pid_t pid, int signal);
-
-
+#ifdef __cplusplus
+}; // extern "C"
+#endif
#endif // ifndef _SIGNAL_H_
diff --git a/src/modules/include/stdio.h b/src/modules/include/stdio.h
index a4d3bb3..b5f34f4 100644
--- a/src/modules/include/stdio.h
+++ b/src/modules/include/stdio.h
@@ -54,6 +54,9 @@ extern FILE* stdin;
extern FILE* stdout;
extern FILE* stderr;
+#ifdef __cplusplus
+extern "C" {
+#endif
int putc(int c, FILE *stream);
int putchar(int c);
@@ -129,4 +132,8 @@ int rename(const char *oldpath, const char *newpath);
/// benutzen zu koennen
int fileno(FILE* io_res);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/modules/include/sys/socket.h b/src/modules/include/sys/socket.h
index 90c7e15..e768524 100644
--- a/src/modules/include/sys/socket.h
+++ b/src/modules/include/sys/socket.h
@@ -82,6 +82,11 @@ enum {
IPPROTO_RAW,
};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* Erstellt einen Socket
*
@@ -173,4 +178,8 @@ int listen(int sock, int backlog);
*/
int accept(int sock, struct sockaddr* address, socklen_t* address_len);
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/modules/include/time.h b/src/modules/include/time.h
index 3fcf5d0..9ba6cdb 100644
--- a/src/modules/include/time.h
+++ b/src/modules/include/time.h
@@ -44,6 +44,10 @@ struct tm {
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
time_t time(time_t* t);
/// Timestamp in tm-Struct einfuellen
@@ -65,5 +69,9 @@ char* asctime(const struct tm* time_ptr);
time_t mktime(struct tm* time_ptr);
#endif
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
diff --git a/src/modules/include/unistd.h b/src/modules/include/unistd.h
index 2e2e3b5..8c5e3ed 100644
--- a/src/modules/include/unistd.h
+++ b/src/modules/include/unistd.h
@@ -47,6 +47,11 @@
int isatty(int desc);
#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/// PID des aktuellen Prozesses auslesen
pid_t getpid(void);
@@ -165,5 +170,9 @@ int gethostname(char* buf, size_t len);
#endif
+#ifdef __cplusplus
+}; // extern "C"
+#endif
+
#endif
--
1.6.0.2