From a79aeed0c1fce8927adf1da0bd9548902a095bae Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 13 May 2015 18:11:02 +0200 Subject: [PATCH] Remove __BEGIN_DECLS and __END_DECLS. --- dispd/client/framebuffer.h | 2 +- dispd/client/session.h | 2 +- dispd/client/window.h | 2 +- kernel/include/sortix/__/dirent.h | 8 ++++++-- kernel/include/sortix/__/dt.h | 8 ++++++-- kernel/include/sortix/__/sigset.h | 8 ++++++-- kernel/include/sortix/__/stat.h | 8 ++++++-- kernel/include/sortix/__/types.h | 8 ++++++-- kernel/include/sortix/__/wait.h | 8 ++++++-- kernel/include/sortix/clock.h | 8 ++++++-- kernel/include/sortix/dirent.h | 8 ++++++-- kernel/include/sortix/display.h | 8 ++++++-- kernel/include/sortix/exit.h | 8 ++++++-- kernel/include/sortix/fcntl.h | 8 ++++++-- kernel/include/sortix/fork.h | 8 ++++++-- kernel/include/sortix/initrd.h | 8 ++++++-- kernel/include/sortix/itimerspec.h | 8 ++++++-- kernel/include/sortix/kernel/kthread.h | 2 +- kernel/include/sortix/limits.h | 8 ++++++-- kernel/include/sortix/mount.h | 8 ++++++-- kernel/include/sortix/poll.h | 8 ++++++-- kernel/include/sortix/resource.h | 8 ++++++-- kernel/include/sortix/seek.h | 8 ++++++-- kernel/include/sortix/sigaction.h | 8 ++++++-- kernel/include/sortix/sigevent.h | 8 ++++++-- kernel/include/sortix/siginfo.h | 8 ++++++-- kernel/include/sortix/signal.h | 8 ++++++-- kernel/include/sortix/sigprocmask.h | 8 ++++++-- kernel/include/sortix/sigset.h | 8 ++++++-- kernel/include/sortix/sigval.h | 8 ++++++-- kernel/include/sortix/socket.h | 8 ++++++-- kernel/include/sortix/stack.h | 8 ++++++-- kernel/include/sortix/stat.h | 8 ++++++-- kernel/include/sortix/statvfs.h | 8 ++++++-- kernel/include/sortix/termios.h | 8 ++++++-- kernel/include/sortix/time.h | 8 ++++++-- kernel/include/sortix/timespec.h | 8 ++++++-- kernel/include/sortix/tmns.h | 8 ++++++-- kernel/include/sortix/ucontext.h | 8 ++++++-- kernel/include/sortix/uio.h | 8 ++++++-- kernel/include/sortix/unistd.h | 8 ++++++-- kernel/include/sortix/uthread.h | 8 ++++++-- kernel/include/sortix/vga.h | 8 ++++++-- kernel/include/sortix/wait.h | 8 ++++++-- kernel/syscall.cpp | 2 +- kernel/x86-family/gdt.cpp | 4 ++-- libc/include/DIR.h | 8 ++++++-- libc/include/FILE.h | 8 ++++++-- libc/include/__/byteswap.h | 8 ++++++-- libc/include/__/endian.h | 8 ++++++-- libc/include/__/stdint.h | 8 ++++++-- libc/include/__/wchar.h | 8 ++++++-- libc/include/alloca.h | 8 ++++++-- libc/include/ar.h | 8 ++++++-- libc/include/argp.h | 8 ++++++-- libc/include/arpa/inet.h | 8 ++++++-- libc/include/assert.h | 8 ++++++-- libc/include/byteswap.h | 8 ++++++-- libc/include/ctype.h | 8 ++++++-- libc/include/dirent.h | 8 ++++++-- libc/include/dlfcn.h | 8 ++++++-- libc/include/elf.h | 8 ++++++-- libc/include/endian.h | 8 ++++++-- libc/include/errno.h | 8 ++++++-- libc/include/error.h | 8 ++++++-- libc/include/fcntl.h | 8 ++++++-- libc/include/fnmatch.h | 8 ++++++-- libc/include/fsmarshall-msg.h | 8 ++++++-- libc/include/fsmarshall.h | 8 ++++++-- libc/include/getopt.h | 8 ++++++-- libc/include/grp.h | 8 ++++++-- libc/include/inttypes.h | 8 ++++++-- libc/include/ioleast.h | 8 ++++++-- libc/include/libgen.h | 8 ++++++-- libc/include/locale.h | 8 ++++++-- libc/include/malloc.h | 8 ++++++-- libc/include/msr.h | 8 ++++++-- libc/include/netdb.h | 8 ++++++-- libc/include/netinet/in.h | 8 ++++++-- libc/include/netinet/tcp.h | 8 ++++++-- libc/include/poll.h | 16 ++++++++++++---- libc/include/pwd.h | 8 ++++++-- libc/include/sched.h | 8 ++++++-- libc/include/setjmp.h | 8 ++++++-- libc/include/signal.h | 8 ++++++-- libc/include/stdint.h | 8 ++++++-- libc/include/stdio.h | 8 ++++++-- libc/include/stdio_ext.h | 8 ++++++-- libc/include/stdlib.h | 8 ++++++-- libc/include/string.h | 8 ++++++-- libc/include/sys/cdefs.h | 9 --------- libc/include/sys/display.h | 8 ++++++-- libc/include/sys/ioctl.h | 8 ++++++-- libc/include/sys/kernelinfo.h | 8 ++++++-- libc/include/sys/mman.h | 8 ++++++-- libc/include/sys/mount.h | 8 ++++++-- libc/include/sys/readdirents.h | 8 ++++++-- libc/include/sys/resource.h | 8 ++++++-- libc/include/sys/select.h | 16 ++++++++++++---- libc/include/sys/socket.h | 16 ++++++++++++---- libc/include/sys/stat.h | 16 ++++++++++++---- libc/include/sys/statvfs.h | 8 ++++++-- libc/include/sys/syscall.h | 10 +++++++--- libc/include/sys/termmode.h | 8 ++++++-- libc/include/sys/time.h | 8 ++++++-- libc/include/sys/times.h | 8 ++++++-- libc/include/sys/types.h | 8 ++++++-- libc/include/sys/uio.h | 16 ++++++++++++---- libc/include/sys/un.h | 8 ++++++-- libc/include/sys/utsname.h | 8 ++++++-- libc/include/sys/wait.h | 8 ++++++-- libc/include/syslog.h | 8 ++++++-- libc/include/system-elf.h | 8 ++++++-- libc/include/termios.h | 8 ++++++-- libc/include/time.h | 24 ++++++++++++++++++------ libc/include/timespec.h | 16 ++++++++++++---- libc/include/unistd.h | 8 ++++++-- libc/include/utime.h | 8 ++++++-- libc/include/wchar.h | 8 ++++++-- libc/include/wctype.h | 8 ++++++-- libc/stdio/fdio.h | 8 ++++++-- libc/stdio/stdio.cpp | 2 +- libm/include/__/math.h | 8 ++++++-- libm/include/complex.h | 8 ++++++-- libm/include/fenv.h | 8 ++++++-- libm/include/ieee754.h | 8 ++++++-- libm/include/ieeefp.h | 8 ++++++-- libm/include/math.h | 8 ++++++-- libpthread/include/__/pthread.h | 8 ++++++-- libpthread/include/pthread.h | 8 ++++++-- libpthread/include/semaphore.h | 8 ++++++-- 131 files changed, 795 insertions(+), 280 deletions(-) diff --git a/dispd/client/framebuffer.h b/dispd/client/framebuffer.h index cfc26f4f..d891e924 100644 --- a/dispd/client/framebuffer.h +++ b/dispd/client/framebuffer.h @@ -41,7 +41,7 @@ struct dispd_framebuffer }; #if defined(__cplusplus) -} // extern "C" +} /* extern "C" */ #endif #endif diff --git a/dispd/client/session.h b/dispd/client/session.h index 2e395e91..60ed9548 100644 --- a/dispd/client/session.h +++ b/dispd/client/session.h @@ -41,7 +41,7 @@ struct dispd_session bool dispd__session_initialize(int* argc, char*** argv); #if defined(__cplusplus) -} // extern "C" +} /* extern "C" */ #endif #endif diff --git a/dispd/client/window.h b/dispd/client/window.h index a90a962a..172b49a2 100644 --- a/dispd/client/window.h +++ b/dispd/client/window.h @@ -37,7 +37,7 @@ struct dispd_window }; #if defined(__cplusplus) -} // extern "C" +} /* extern "C" */ #endif #endif diff --git a/kernel/include/sortix/__/dirent.h b/kernel/include/sortix/__/dirent.h index 7bfacd38..c09ac012 100644 --- a/kernel/include/sortix/__/dirent.h +++ b/kernel/include/sortix/__/dirent.h @@ -30,11 +30,15 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define __IFTODT(mode) (((mode) & __S_IFMT) >> __S_IFMT_SHIFT) #define __DTTOIF(dirtype) ((dirtype) << __S_IFMT_SHIFT) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/__/dt.h b/kernel/include/sortix/__/dt.h index 65b8b706..67f7e667 100644 --- a/kernel/include/sortix/__/dt.h +++ b/kernel/include/sortix/__/dt.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define __DT_UNKNOWN 0x0 #define __DT_FIFO 0x1 @@ -39,6 +41,8 @@ __BEGIN_DECLS #define __DT_SOCK 0xC #define __DT_BITS 0xF -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/__/sigset.h b/kernel/include/sortix/__/sigset.h index 99cbd357..fd719951 100644 --- a/kernel/include/sortix/__/sigset.h +++ b/kernel/include/sortix/__/sigset.h @@ -27,10 +27,14 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define __SIGSET_NUM_SIGNALS 128 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/__/stat.h b/kernel/include/sortix/__/stat.h index 8ba4c970..44c1f6e7 100644 --- a/kernel/include/sortix/__/stat.h +++ b/kernel/include/sortix/__/stat.h @@ -30,11 +30,15 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define __S_IFMT_SHIFT 12 #define __S_IFMT_MASK __DT_BITS -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/__/types.h b/kernel/include/sortix/__/types.h index fdb25621..cad03d2e 100644 --- a/kernel/include/sortix/__/types.h +++ b/kernel/include/sortix/__/types.h @@ -31,7 +31,9 @@ #include <__/stdint.h> #include <__/wordsize.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif typedef __intmax_t __blkcnt_t; /*#define __BLKCNT_UNSIGNED*/ @@ -400,6 +402,8 @@ typedef __uint64_t __uid_t; #define __SCNuUID __SCNu64 #define __SCNxUID __SCNx64 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/__/wait.h b/kernel/include/sortix/__/wait.h index 75081d6c..2d88b95f 100644 --- a/kernel/include/sortix/__/wait.h +++ b/kernel/include/sortix/__/wait.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define __WNATURE_EXITED 0 #define __WNATURE_SIGNALED 1 @@ -50,6 +52,8 @@ __BEGIN_DECLS ((exitcode) & 0xFF) << 8 | \ ((signal) & 0x7F) << 0) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/clock.h b/kernel/include/sortix/clock.h index 6db6c0f9..ba4b354b 100644 --- a/kernel/include/sortix/clock.h +++ b/kernel/include/sortix/clock.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define CLOCK_REALTIME 0 /* Current real time. */ #define CLOCK_MONOTONIC 1 /* Always increasing time. */ @@ -40,6 +42,8 @@ __BEGIN_DECLS #define CLOCK_THREAD_CPUTIME_ID 8 #define CLOCK_THREAD_SYSTIME_ID 9 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/dirent.h b/kernel/include/sortix/dirent.h index 0401e9f9..9288496f 100644 --- a/kernel/include/sortix/dirent.h +++ b/kernel/include/sortix/dirent.h @@ -34,7 +34,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __dev_t_defined #define __dev_t_defined @@ -87,6 +89,8 @@ static __inline struct kernel_dirent* kernel_dirent_next(struct kernel_dirent* e return (struct kernel_dirent*) ((uint8_t*) ent + ent->d_nextoff); } -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/display.h b/kernel/include/sortix/display.h index 38b43342..13d625b5 100644 --- a/kernel/include/sortix/display.h +++ b/kernel/include/sortix/display.h @@ -30,7 +30,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif const uint32_t DISPMSG_CONTROL_VALID = 1 << 0; const uint32_t DISPMSG_CONTROL_VGA = 1 << 1; @@ -163,6 +165,8 @@ struct dispmsg_read_memory uint8_t* dst; // in, *out }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/exit.h b/kernel/include/sortix/exit.h index 25fc194f..c4b6730e 100644 --- a/kernel/include/sortix/exit.h +++ b/kernel/include/sortix/exit.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -55,6 +57,8 @@ struct exit_thread #define EXIT_THREAD_PROCESS (1<<4) #define EXIT_THREAD_DUMP_CORE (1<<5) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/fcntl.h b/kernel/include/sortix/fcntl.h index b209aef7..992a9c17 100644 --- a/kernel/include/sortix/fcntl.h +++ b/kernel/include/sortix/fcntl.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Remember to update the flag classifications at the top of descriptor.cpp if you add new flags here. */ @@ -114,6 +116,8 @@ __BEGIN_DECLS #define AT_REMOVEFILE (1<<3) #define AT_SYMLINK_FOLLOW (1<<4) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/fork.h b/kernel/include/sortix/fork.h index 780277a7..4961abcc 100644 --- a/kernel/include/sortix/fork.h +++ b/kernel/include/sortix/fork.h @@ -32,7 +32,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* The sfork system call is much like the rfork system call found in Plan 9 and BSD systems, however it works slightly differently and was renamed to avoid @@ -122,6 +124,8 @@ struct tfork stack_t altstack; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/initrd.h b/kernel/include/sortix/initrd.h index 28a6068a..f95edc55 100644 --- a/kernel/include/sortix/initrd.h +++ b/kernel/include/sortix/initrd.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define INITRD_ALGO_CRC32 0 @@ -97,6 +99,8 @@ typedef struct initrd_dirent char name[0]; } initrd_dirent_t; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/itimerspec.h b/kernel/include/sortix/itimerspec.h index f7cfaf9a..eaec169a 100644 --- a/kernel/include/sortix/itimerspec.h +++ b/kernel/include/sortix/itimerspec.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif struct itimerspec { @@ -37,6 +39,8 @@ struct itimerspec struct timespec it_value; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/kernel/kthread.h b/kernel/include/sortix/kernel/kthread.h index af9e3467..93c46ac1 100644 --- a/kernel/include/sortix/kernel/kthread.h +++ b/kernel/include/sortix/kernel/kthread.h @@ -55,7 +55,7 @@ unsigned long kthread_cond_wait_signal(kthread_cond_t* cond, kthread_mutex_t* mu void kthread_cond_signal(kthread_cond_t* cond); void kthread_cond_broadcast(kthread_cond_t* cond); -} // extern "C" +} /* extern "C" */ class ScopedLock { diff --git a/kernel/include/sortix/limits.h b/kernel/include/sortix/limits.h index 53e83a0c..2cbe11b9 100644 --- a/kernel/include/sortix/limits.h +++ b/kernel/include/sortix/limits.h @@ -27,10 +27,14 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define HOST_NAME_MAX 255 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/mount.h b/kernel/include/sortix/mount.h index 9b899999..f9471134 100644 --- a/kernel/include/sortix/mount.h +++ b/kernel/include/sortix/mount.h @@ -27,12 +27,16 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define UNMOUNT_FORCE (1 << 0) #define UNMOUNT_DETACH (1 << 1) #define UNMOUNT_NOFOLLOW (1 << 2) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/poll.h b/kernel/include/sortix/poll.h index 4800aedb..ffd44829 100644 --- a/kernel/include/sortix/poll.h +++ b/kernel/include/sortix/poll.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif typedef __SIZE_TYPE__ nfds_t; @@ -52,6 +54,8 @@ struct pollfd #define POLL__ONLY_REVENTS (POLLERR | POLLHUP | POLLNVAL) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/resource.h b/kernel/include/sortix/resource.h index fb4a6702..99ce6552 100644 --- a/kernel/include/sortix/resource.h +++ b/kernel/include/sortix/resource.h @@ -29,7 +29,9 @@ #include <__/stdint.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define PRIO_PROCESS 0 #define PRIO_PGRP 1 @@ -60,6 +62,8 @@ struct rlimit #define RLIMIT_NUM_DECLARED __RLIMIT_NUM_DECLARED #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/seek.h b/kernel/include/sortix/seek.h index 689d585d..76f0425a 100644 --- a/kernel/include/sortix/seek.h +++ b/kernel/include/sortix/seek.h @@ -27,12 +27,16 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define SEEK_SET 0 /* Seek from beginning of file. */ #define SEEK_CUR 1 /* Seek from current position. */ #define SEEK_END 2 /* Seek from end of file. */ -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/sigaction.h b/kernel/include/sortix/sigaction.h index a2b03b80..990c222e 100644 --- a/kernel/include/sortix/sigaction.h +++ b/kernel/include/sortix/sigaction.h @@ -30,7 +30,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define SA_NOCLDSTOP (1<<0) #define SA_ONSTACK (1<<1) @@ -58,6 +60,8 @@ struct sigaction int sa_flags; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/sigevent.h b/kernel/include/sortix/sigevent.h index 8011a707..50e5d1c7 100644 --- a/kernel/include/sortix/sigevent.h +++ b/kernel/include/sortix/sigevent.h @@ -33,7 +33,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if __STDC_HOSTED__ #ifndef __pthread_attr_t_defined @@ -59,6 +61,8 @@ struct sigevent #endif }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/siginfo.h b/kernel/include/sortix/siginfo.h index fe040ca3..f3c1ad47 100644 --- a/kernel/include/sortix/siginfo.h +++ b/kernel/include/sortix/siginfo.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __pid_t_defined #define __pid_t_defined @@ -91,6 +93,8 @@ typedef struct #define SI_ASYNCIO 34 #define SI_MSGQ 35 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/signal.h b/kernel/include/sortix/signal.h index a0a24fb2..2ac28ec2 100644 --- a/kernel/include/sortix/signal.h +++ b/kernel/include/sortix/signal.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define SIGHUP 1 /* Hangup */ #define SIGINT 2 /* Interrupt */ @@ -72,6 +74,8 @@ __BEGIN_DECLS #define SIG_DFL ((void (*)(int)) 0) #define SIG_IGN ((void (*)(int)) 1) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/sigprocmask.h b/kernel/include/sortix/sigprocmask.h index 8260adff..798cfb69 100644 --- a/kernel/include/sortix/sigprocmask.h +++ b/kernel/include/sortix/sigprocmask.h @@ -27,12 +27,16 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define SIG_BLOCK 0 #define SIG_UNBLOCK 1 #define SIG_SETMASK 2 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/sigset.h b/kernel/include/sortix/sigset.h index 80becb8d..cf29c8d4 100644 --- a/kernel/include/sortix/sigset.h +++ b/kernel/include/sortix/sigset.h @@ -29,13 +29,17 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif typedef struct { unsigned long __val[__SIGSET_NUM_SIGNALS / (8 * sizeof(unsigned long int))]; } sigset_t; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/sigval.h b/kernel/include/sortix/sigval.h index b2b6adb9..9381558b 100644 --- a/kernel/include/sortix/sigval.h +++ b/kernel/include/sortix/sigval.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif union sigval { @@ -35,6 +37,8 @@ union sigval void* sival_ptr; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/socket.h b/kernel/include/sortix/socket.h index 43cc8a46..cf32905b 100644 --- a/kernel/include/sortix/socket.h +++ b/kernel/include/sortix/socket.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* TODO: Nicely wrap this in an enum, as in glibc's header? */ #define SOCK_TYPE_MASK ((1<<20)-1) @@ -40,6 +42,8 @@ __BEGIN_DECLS #define SOCK_CLOEXEC (1<<21) #define SOCK_CLOFORK (1<<22) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/stack.h b/kernel/include/sortix/stack.h index a4945d27..fd1a3a01 100644 --- a/kernel/include/sortix/stack.h +++ b/kernel/include/sortix/stack.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -49,6 +51,8 @@ typedef struct int ss_flags; } stack_t; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/stat.h b/kernel/include/sortix/stat.h index e77de5bb..8df20c3d 100644 --- a/kernel/include/sortix/stat.h +++ b/kernel/include/sortix/stat.h @@ -36,7 +36,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif struct stat { @@ -87,6 +89,8 @@ struct stat #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/statvfs.h b/kernel/include/sortix/statvfs.h index 6fe77094..3456dc02 100644 --- a/kernel/include/sortix/statvfs.h +++ b/kernel/include/sortix/statvfs.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __dev_t_defined #define __dev_t_defined @@ -64,6 +66,8 @@ struct statvfs #define ST_RDONLY (1 << 0) #define ST_NOSUID (1 << 1) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/termios.h b/kernel/include/sortix/termios.h index bcb30f15..0096baa2 100644 --- a/kernel/include/sortix/termios.h +++ b/kernel/include/sortix/termios.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -51,6 +53,8 @@ struct winsize size_t ws_ypixel; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/time.h b/kernel/include/sortix/time.h index 8d0755c8..850156f8 100644 --- a/kernel/include/sortix/time.h +++ b/kernel/include/sortix/time.h @@ -27,10 +27,14 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define TIMER_ABSTIME (1<<0) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/timespec.h b/kernel/include/sortix/timespec.h index 9cac3dc1..c584ec1b 100644 --- a/kernel/include/sortix/timespec.h +++ b/kernel/include/sortix/timespec.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __time_t_defined #define __time_t_defined @@ -42,6 +44,8 @@ struct timespec long tv_nsec; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/tmns.h b/kernel/include/sortix/tmns.h index 8aa53296..66a7ad66 100644 --- a/kernel/include/sortix/tmns.h +++ b/kernel/include/sortix/tmns.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif struct tmns { @@ -39,6 +41,8 @@ struct tmns struct timespec tmns_cstime; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/ucontext.h b/kernel/include/sortix/ucontext.h index 5d36b0d8..3083b959 100644 --- a/kernel/include/sortix/ucontext.h +++ b/kernel/include/sortix/ucontext.h @@ -30,7 +30,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Register declarations for i386 */ #if defined(__i386__) @@ -150,6 +152,8 @@ typedef struct ucontext mcontext_t uc_mcontext; } ucontext_t; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/uio.h b/kernel/include/sortix/uio.h index 1ce39055..908c05ee 100644 --- a/kernel/include/sortix/uio.h +++ b/kernel/include/sortix/uio.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -43,6 +45,8 @@ struct iovec size_t iov_len; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/unistd.h b/kernel/include/sortix/unistd.h index 93fe4aef..094421d0 100644 --- a/kernel/include/sortix/unistd.h +++ b/kernel/include/sortix/unistd.h @@ -27,13 +27,17 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define R_OK 4 /* Test for read permission. */ #define W_OK 2 /* Test for write permission. */ #define X_OK 1 /* Test for execute permission. */ #define F_OK 0 /* Test for existence. */ -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/uthread.h b/kernel/include/sortix/uthread.h index a2049741..125ce268 100644 --- a/kernel/include/sortix/uthread.h +++ b/kernel/include/sortix/uthread.h @@ -35,7 +35,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define UTHREAD_FLAG_INITIAL (1UL << 0UL) @@ -56,6 +58,8 @@ struct uthread size_t __uthread_reserved[4]; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/vga.h b/kernel/include/sortix/vga.h index 6cc07db8..13c2dee1 100644 --- a/kernel/include/sortix/vga.h +++ b/kernel/include/sortix/vga.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define COLOR8_BLACK 0 #define COLOR8_BLUE 1 @@ -46,6 +48,8 @@ __BEGIN_DECLS #define COLOR8_LIGHT_BROWN 14 #define COLOR8_WHITE 15 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/include/sortix/wait.h b/kernel/include/sortix/wait.h index 749a36cd..db0a27ab 100644 --- a/kernel/include/sortix/wait.h +++ b/kernel/include/sortix/wait.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define WCONTINUED (1<<0) #define WNOHANG (1<<1) @@ -54,6 +56,8 @@ __BEGIN_DECLS #define WCONSTRUCT(nature, exitcode, signal) \ __WCONSTRUCT(nature, exitcode, signal) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/kernel/syscall.cpp b/kernel/syscall.cpp index 2895cd54..693b8d2e 100644 --- a/kernel/syscall.cpp +++ b/kernel/syscall.cpp @@ -190,7 +190,7 @@ void* syscall_list[SYSCALL_MAX_NUM + 1] = [SYSCALL_CLOSEFROM] = (void*) sys_closefrom, [SYSCALL_MAX_NUM] = (void*) sys_bad_syscall, }; -} // extern "C" +} /* extern "C" */ int sys_bad_syscall(void) { diff --git a/kernel/x86-family/gdt.cpp b/kernel/x86-family/gdt.cpp index 478e90f3..ebe25bf4 100644 --- a/kernel/x86-family/gdt.cpp +++ b/kernel/x86-family/gdt.cpp @@ -152,7 +152,7 @@ struct tss_entry tss = #endif }; -} // extern "C" +} /* extern "C" */ #define GRAN_64_BIT_MODE (1 << 5) #define GRAN_32_BIT_MODE (1 << 6) @@ -230,7 +230,7 @@ struct gdt_entry gdt[] = uint16_t gdt_size_minus_one = sizeof(gdt) - 1; -} // extern "C" +} /* extern "C" */ uintptr_t GetKernelStack() { diff --git a/libc/include/DIR.h b/libc/include/DIR.h index 948b238a..473ee720 100644 --- a/libc/include/DIR.h +++ b/libc/include/DIR.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -72,6 +74,8 @@ extern DIR* __first_dir; extern __pthread_mutex_t __first_dir_lock; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/FILE.h b/libc/include/FILE.h index 83c377f5..c9654b97 100644 --- a/libc/include/FILE.h +++ b/libc/include/FILE.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __off_t_defined #define __off_t_defined @@ -104,6 +106,8 @@ extern FILE* __first_file; extern __pthread_mutex_t __first_file_lock; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/__/byteswap.h b/libc/include/__/byteswap.h index e9b536ef..50184f34 100644 --- a/libc/include/__/byteswap.h +++ b/libc/include/__/byteswap.h @@ -27,13 +27,17 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Use compiler builtins for efficient byte swapping. */ #define __bswap_16(x) __builtin_bswap16(x) #define __bswap_32(x) __builtin_bswap32(x) #define __bswap_64(x) __builtin_bswap64(x) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/__/endian.h b/libc/include/__/endian.h index 26e513c4..c9d97d62 100644 --- a/libc/include/__/endian.h +++ b/libc/include/__/endian.h @@ -29,7 +29,9 @@ #include <__/byteswap.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* The compiler provides the type constants. */ #define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ @@ -81,7 +83,9 @@ __BEGIN_DECLS #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif /* Sortix specific extensions only available in C++. */ #if defined(__cplusplus) diff --git a/libc/include/__/stdint.h b/libc/include/__/stdint.h index 6d184156..f9a9cb3c 100644 --- a/libc/include/__/stdint.h +++ b/libc/include/__/stdint.h @@ -29,7 +29,9 @@ #include <__/wordsize.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* TODO: Make the compiler provide all this information using __ prefix. */ /* TODO: Use __XINTXX_TYPE__ constants when switching to gcc 4.7.x or newer. */ @@ -500,6 +502,8 @@ typedef long long unsigned int __uintmax_t; /* TODO: Should these come from a <__stddef.h>? */ #define __SIZE_MAX __SIZE_MAX__ -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/__/wchar.h b/libc/include/__/wchar.h index 3b7a2f78..94bae536 100644 --- a/libc/include/__/wchar.h +++ b/libc/include/__/wchar.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif typedef __WCHAR_TYPE__ __wchar_t; #define __WCHAR_MIN __WCHAR_MIN__ @@ -39,6 +41,8 @@ typedef __WINT_TYPE__ __wint_t; #define __WEOF __WINT_MAX -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/alloca.h b/libc/include/alloca.h index 35839868..d085fb7a 100644 --- a/libc/include/alloca.h +++ b/libc/include/alloca.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -52,6 +54,8 @@ void* alloca(size_t); error if -fno-builtin is passed. */ #define alloca(size) __builtin_alloca(size) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/ar.h b/libc/include/ar.h index 9823b3b7..c12dadfa 100644 --- a/libc/include/ar.h +++ b/libc/include/ar.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Archive files start with the ARMAG identifying string. Then follows a `struct ar_hdr', and as many bytes of member file data as its `ar_size' @@ -53,6 +55,8 @@ struct ar_hdr char ar_fmag[2]; /* Always contains ARFMAG. */ }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/argp.h b/libc/include/argp.h index e45f4982..8eab60d2 100644 --- a/libc/include/argp.h +++ b/libc/include/argp.h @@ -29,8 +29,12 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/arpa/inet.h b/libc/include/arpa/inet.h index 9fb2486b..11fbbede 100644 --- a/libc/include/arpa/inet.h +++ b/libc/include/arpa/inet.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Functions from POSIX that is considered obsolete due to bad design. */ #if __USE_POSIX @@ -49,6 +51,8 @@ int inet_pton(int, const char* __restrict, void* __restrict); /* TODO: char* inet_neta(in_addr_t, char*, size_t); */ #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/assert.h b/libc/include/assert.h index 958eaa5a..939b0d30 100644 --- a/libc/include/assert.h +++ b/libc/include/assert.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Determine how the value should be cast to void. */ #if defined __cplusplus @@ -45,7 +47,9 @@ __BEGIN_DECLS __attribute__((noreturn)) void __assert(const char*, unsigned long, const char*, const char*); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/byteswap.h b/libc/include/byteswap.h index fa47ff42..3b0a8525 100644 --- a/libc/include/byteswap.h +++ b/libc/include/byteswap.h @@ -29,13 +29,17 @@ #include <__/byteswap.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Easy byte swapping of integers. */ #define bswap_16(x) __bswap_16(x) #define bswap_32(x) __bswap_32(x) #define bswap_64(x) __bswap_64(x) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/ctype.h b/libc/include/ctype.h index a7dd2dd1..cf0ad902 100644 --- a/libc/include/ctype.h +++ b/libc/include/ctype.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __locale_t_defined #define __locale_t_defined @@ -68,6 +70,8 @@ int tolower(int c); int toupper(int c); /* TODO: toupper_l */ -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/dirent.h b/libc/include/dirent.h index a26a4084..2ef49b75 100644 --- a/libc/include/dirent.h +++ b/libc/include/dirent.h @@ -35,7 +35,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __dev_t_defined #define __dev_t_defined @@ -130,6 +132,8 @@ void dunregister(DIR* dir); int versionsort_r(const struct dirent**, const struct dirent**, void*); #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/dlfcn.h b/libc/include/dlfcn.h index e2768e7a..5d4633bf 100644 --- a/libc/include/dlfcn.h +++ b/libc/include/dlfcn.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define RTLD_LAZY (1<<0) #define RTLD_NOW (1<<1) @@ -39,6 +41,8 @@ char* dlerror(); void* dlopen(const char* filename, int mode); void* dlsym(void* handle, const char* name); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/elf.h b/libc/include/elf.h index a49f6e44..8c522f26 100644 --- a/libc/include/elf.h +++ b/libc/include/elf.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Standard ELF types. */ @@ -3086,6 +3088,8 @@ typedef Elf32_Addr Elf32_Conflict; #define R_TILEGX_NUM 130 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/endian.h b/libc/include/endian.h index aae5f15e..5225f6cc 100644 --- a/libc/include/endian.h +++ b/libc/include/endian.h @@ -29,7 +29,9 @@ #include <__/endian.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Constans for each kind of known endian. */ #define LITTLE_ENDIAN __LITTLE_ENDIAN @@ -57,7 +59,9 @@ __BEGIN_DECLS #define be64toh(x) __be64toh(x) #define le64toh(x) __le64toh(x) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif /* Sortix specific extensions only available in C++. */ #if defined(__cplusplus) diff --git a/libc/include/errno.h b/libc/include/errno.h index 4441d350..5caea8b7 100644 --- a/libc/include/errno.h +++ b/libc/include/errno.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define ENOTBLK 12 #define ENODEV 13 @@ -145,6 +147,8 @@ extern char* program_invocation_short_name; #define program_invocation_name program_invocation_name #define program_invocation_short_name program_invocation_short_name -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/error.h b/libc/include/error.h index c8d1c655..0b1dbe0e 100644 --- a/libc/include/error.h +++ b/libc/include/error.h @@ -27,13 +27,17 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif void gnu_error(int status, int errnum, const char* format, ...) __attribute__((__format__(__printf__, 3, 4))); void error(int status, int errnum, const char* format, ...) __asm__ ("gnu_error") __attribute__((__format__(__printf__, 3, 4))); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index 93b3eb2f..5bd42fb9 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -34,7 +34,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* The kernel would like to simply deal with one bit for each base access mode, but using the traditional names O_RDONLY, O_WRONLY and O_RDWR for this would @@ -59,6 +61,8 @@ int fcntl(int fd, int cmd, ...); int open(const char* path, int oflag, ...); int openat(int fd, const char* path, int oflag, ...); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/fnmatch.h b/libc/include/fnmatch.h index ab71223a..a631d71b 100644 --- a/libc/include/fnmatch.h +++ b/libc/include/fnmatch.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define FNM_NOMATCH 1 @@ -37,6 +39,8 @@ __BEGIN_DECLS int fnmatch(const char*, const char*, int); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/fsmarshall-msg.h b/libc/include/fsmarshall-msg.h index a2f41759..15084b9d 100644 --- a/libc/include/fsmarshall-msg.h +++ b/libc/include/fsmarshall-msg.h @@ -34,7 +34,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define FSM_MOUNT_CLOEXEC (1 << 0) #define FSM_MOUNT_CLOFORK (1 << 1) @@ -433,6 +435,8 @@ struct fsm_resp_tcgetwincurpos #define FSM_MSG_NUM 53 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/fsmarshall.h b/libc/include/fsmarshall.h index 63709662..e3328b8c 100644 --- a/libc/include/fsmarshall.h +++ b/libc/include/fsmarshall.h @@ -29,13 +29,17 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif struct stat; int fsm_fsbind(int, int, int); int fsm_mountat(int, const char*, const struct stat*, int); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/getopt.h b/libc/include/getopt.h index 3c48f46f..ebe79e98 100644 --- a/libc/include/getopt.h +++ b/libc/include/getopt.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* These declarations are repeated in . */ #ifndef __getopt_unistd_shared_declared @@ -54,6 +56,8 @@ struct option int getopt_long(int, char* const*, const char*, const struct option*, int*); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/grp.h b/libc/include/grp.h index b79ef419..44858d2e 100644 --- a/libc/include/grp.h +++ b/libc/include/grp.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __FILE_defined #define __FILE_defined @@ -74,6 +76,8 @@ int getgrnam_r(const char*, struct group*, char*, size_t, struct group**); FILE* opengr(void); void setgrent(void); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/inttypes.h b/libc/include/inttypes.h index c2d9bcf7..c9ce4d56 100644 --- a/libc/include/inttypes.h +++ b/libc/include/inttypes.h @@ -203,7 +203,9 @@ #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __wchar_t_defined #define __wchar_t_defined @@ -224,6 +226,8 @@ uintmax_t strtoumax(const char* __restrict, char** __restrict, int); intmax_t wcstoimax(const wchar_t* __restrict, wchar_t** __restrict, int); uintmax_t wcstoumax(const wchar_t* __restrict, wchar_t** __restrict, int); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/ioleast.h b/libc/include/ioleast.h index 3965f243..d25a305a 100644 --- a/libc/include/ioleast.h +++ b/libc/include/ioleast.h @@ -32,7 +32,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __off_t_defined #define __off_t_defined @@ -54,6 +56,8 @@ size_t readleast(int fd, void* buf, size_t least, size_t max); size_t writeall(int fd, const void* buf, size_t count); size_t writeleast(int fd, const void* buf, size_t least, size_t max); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/libgen.h b/libc/include/libgen.h index 909531f2..4dcdac8c 100644 --- a/libc/include/libgen.h +++ b/libc/include/libgen.h @@ -27,11 +27,15 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif char* dirname(char* path); char* basename(char* path); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/locale.h b/libc/include/locale.h index e2612178..eb9573fa 100644 --- a/libc/include/locale.h +++ b/libc/include/locale.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif struct lconv { @@ -76,6 +78,8 @@ char* setlocale(int category, const char* locale); #endif struct lconv* localeconv(void); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/malloc.h b/libc/include/malloc.h index 07603ab0..852a228b 100644 --- a/libc/include/malloc.h +++ b/libc/include/malloc.h @@ -41,7 +41,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int heap_get_paranoia(void); /* TODO: Operations to verify pointers and consistency check the heap. */ @@ -632,7 +634,9 @@ struct heap_chunk* heap_chunk_combine_neighbors(struct heap_chunk* chunk) #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #if __is_sortix_libc #include diff --git a/libc/include/msr.h b/libc/include/msr.h index 386d13d0..59e833e2 100644 --- a/libc/include/msr.h +++ b/libc/include/msr.h @@ -32,7 +32,9 @@ #if defined(__i386__) || defined(__x86_64__) -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define MSRID_FSBASE __UINT32_C(0xC0000100) #define MSRID_GSBASE __UINT32_C(0xC0000101) @@ -90,7 +92,9 @@ static __inline void wrmsr_split(uint32_t msrid, uint32_t low, uint32_t high) wrmsr(msrid, (uint64_t) low << 0 | (uint64_t) high << 32); } -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/netdb.h b/libc/include/netdb.h index 4156e722..42d4503e 100644 --- a/libc/include/netdb.h +++ b/libc/include/netdb.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __in_port_t_defined #define __in_port_t_defined @@ -144,6 +146,8 @@ void setnetent(int); void setprotoent(int); void setservent(int); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/netinet/in.h b/libc/include/netinet/in.h index 87ddedf6..b9cd85c2 100644 --- a/libc/include/netinet/in.h +++ b/libc/include/netinet/in.h @@ -32,7 +32,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __in_port_t_defined #define __in_port_t_defined @@ -140,6 +142,8 @@ IN6_IS_ADDR_MC_GLOBAL && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \ && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3])) -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/netinet/tcp.h b/libc/include/netinet/tcp.h index a750918f..5a34af33 100644 --- a/libc/include/netinet/tcp.h +++ b/libc/include/netinet/tcp.h @@ -27,11 +27,15 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Options at the IPPROTO_TCP socket level. */ #define TCP_NODELAY 1 -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/poll.h b/libc/include/poll.h index 7104b817..101bef8c 100644 --- a/libc/include/poll.h +++ b/libc/include/poll.h @@ -29,23 +29,31 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __time_t_defined #define __time_t_defined typedef __time_t time_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #include #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int poll(struct pollfd* fds, nfds_t nfds, int timeout); int ppoll(struct pollfd* fds, nfds_t nfds, const struct timespec* timeout, const sigset_t* sigmask); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/pwd.h b/libc/include/pwd.h index 7ceeeec9..7947810b 100644 --- a/libc/include/pwd.h +++ b/libc/include/pwd.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __FILE_defined #define __FILE_defined @@ -83,6 +85,8 @@ int getpwuid_r(uid_t, struct passwd* __restrict, char* __restrict, size_t, FILE* openpw(void); void setpwent(void); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sched.h b/libc/include/sched.h index f969976c..b35f59b4 100644 --- a/libc/include/sched.h +++ b/libc/include/sched.h @@ -27,10 +27,14 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int sched_yield(void); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/setjmp.h b/libc/include/setjmp.h index dbba193d..4e0cdba2 100644 --- a/libc/include/setjmp.h +++ b/libc/include/setjmp.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if defined(__x86_64__) typedef unsigned long sigjmp_buf[8 + 1 + __SIGSET_NUM_SIGNALS / (sizeof(unsigned long int) * 8)]; @@ -46,6 +48,8 @@ int setjmp(jmp_buf); void siglongjmp(sigjmp_buf, int); int sigsetjmp(sigjmp_buf, int); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/signal.h b/libc/include/signal.h index 0dc7b1d0..64a0cc42 100644 --- a/libc/include/signal.h +++ b/libc/include/signal.h @@ -45,7 +45,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __uid_t_defined #define __uid_t_defined @@ -112,6 +114,8 @@ int sigsuspend(const sigset_t*); /* TODO: int sigwait(const sigset_t* __restrict, int* __restrict); */ /* TODO: int sigwaitinfo(const sigset_t* __restrict, siginfo_t* __restrict); */ -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/stdint.h b/libc/include/stdint.h index 5ed42256..f9330da5 100644 --- a/libc/include/stdint.h +++ b/libc/include/stdint.h @@ -30,7 +30,9 @@ #include <__/stdint.h> #include <__/wchar.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Only define these constant macros in C++ if requested. */ #if __USE_SORTIX || defined(__STDC_CONSTANT_MACROS) || !defined(__cplusplus) @@ -168,6 +170,8 @@ typedef __uintptr_t uintptr_t; typedef __intmax_t intmax_t; typedef __uintmax_t uintmax_t; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 4a147473..51d9da40 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -44,7 +44,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if __USE_SORTIX || 2008 <= __USE_POSIX #ifndef __off_t_defined @@ -317,6 +319,8 @@ int vscanf_callback(void* fp, __attribute__((__format__ (scanf, 4, 0))); #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/stdio_ext.h b/libc/include/stdio_ext.h index ba6b49ce..01e46a34 100644 --- a/libc/include/stdio_ext.h +++ b/libc/include/stdio_ext.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif size_t __fbufsize(FILE* fp); size_t __fpending(FILE* fp); @@ -40,6 +42,8 @@ void __fseterr(FILE* fp); int __fwritable(FILE* fp); int __fwriting(FILE* fp); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index 4cde309f..038aadab 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -35,7 +35,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define EXIT_SUCCESS (0) #define EXIT_FAILURE (1) @@ -181,6 +183,8 @@ uint32_t arc4random_uniform(uint32_t); void* reallocarray(void*, size_t, size_t); #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/string.h b/libc/include/string.h index e55bc1f1..22f706cf 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef NULL #define __need_NULL @@ -169,6 +171,8 @@ const char* sortix_strsignal(int signum); })) #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index 1b6361db..903219cd 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -37,15 +37,6 @@ string that contains the warning. */ #define __PRAGMA_WARNING(msg) _Pragma(__STRINGIFY(GCC warning msg)) -/* C++ needs to know that types and declarations are C, not C++. */ -#ifdef __cplusplus - #define __BEGIN_DECLS extern "C" { - #define __END_DECLS } -#else - #define __BEGIN_DECLS - #define __END_DECLS -#endif - /* Use the real restrict keyword if it is available. Not that this really matters as gcc uses __restrict and __restrict__ as aliases for restrict, but it will look nicer after preprocessing. */ diff --git a/libc/include/sys/display.h b/libc/include/sys/display.h index 18ac5df8..54004c1d 100644 --- a/libc/include/sys/display.h +++ b/libc/include/sys/display.h @@ -31,10 +31,14 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int dispmsg_issue(void* ptr, size_t size); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/ioctl.h b/libc/include/sys/ioctl.h index 250eecdf..135d4e83 100644 --- a/libc/include/sys/ioctl.h +++ b/libc/include/sys/ioctl.h @@ -27,10 +27,14 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int ioctl(int fd, int request, ...); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/kernelinfo.h b/libc/include/sys/kernelinfo.h index f518fd8e..ad68a838 100644 --- a/libc/include/sys/kernelinfo.h +++ b/libc/include/sys/kernelinfo.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -44,6 +46,8 @@ typedef __ssize_t ssize_t; ssize_t kernelinfo(const char* req, char* resp, size_t resplen); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h index 059de1f7..cdd2c04b 100644 --- a/libc/include/sys/mman.h +++ b/libc/include/sys/mman.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __mode_t_defined #define __mode_t_defined @@ -53,6 +55,8 @@ void* mmap(void*, size_t, int, int, int, off_t); int mprotect(const void*, size_t, int); int munmap(void*, size_t); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/mount.h b/libc/include/sys/mount.h index 54e81a5a..d401cbbf 100644 --- a/libc/include/sys/mount.h +++ b/libc/include/sys/mount.h @@ -29,11 +29,15 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int unmount(const char*, int); int unmountat(int, const char*, int); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/readdirents.h b/libc/include/sys/readdirents.h index 56373ef8..0797fbf8 100644 --- a/libc/include/sys/readdirents.h +++ b/libc/include/sys/readdirents.h @@ -34,7 +34,9 @@ #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -44,6 +46,8 @@ __BEGIN_DECLS ssize_t readdirents(int fd, struct kernel_dirent* dirent, size_t size); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/resource.h b/libc/include/sys/resource.h index a7aa36da..5b469377 100644 --- a/libc/include/sys/resource.h +++ b/libc/include/sys/resource.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __id_t_defined #define __id_t_defined @@ -78,6 +80,8 @@ int prlimit(pid_t, int, const struct rlimit*, struct rlimit*); int setpriority(int, id_t, int); int setrlimit(int, const struct rlimit*); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h index e405792b..ce0cfd22 100644 --- a/libc/include/sys/select.h +++ b/libc/include/sys/select.h @@ -32,7 +32,9 @@ #include /* TODO: HACK: for FD_ZERO */ -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __time_t_defined #define __time_t_defined @@ -53,10 +55,14 @@ struct timeval }; #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #include #include -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #define FD_SETSIZE 1024 #define __FD_ELEM_SIZE ((int) sizeof(__fd_mask)) @@ -81,6 +87,8 @@ typedef struct int select(int, fd_set* __restrict, fd_set* __restrict, fd_set* __restrict, struct timeval* __restrict); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h index b257f611..c5a83315 100644 --- a/libc/include/sys/socket.h +++ b/libc/include/sys/socket.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __socklen_t_defined #define __socklen_t_defined @@ -54,11 +56,15 @@ typedef __ssize_t ssize_t; typedef unsigned short int sa_family_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif struct sockaddr { @@ -181,6 +187,8 @@ int sockatmark(int); int socket(int, int, int); int socketpair(int, int, int, int[2]); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 975e6bc5..929adc95 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __blkcnt_t_defined #define __blkcnt_t_defined @@ -81,12 +83,16 @@ typedef __off_t off_t; typedef __time_t time_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* POSIX mandates that we define these compatibility macros to support programs that are yet to embrace struct timespec. */ @@ -114,6 +120,8 @@ int utimens(const char* path, const struct timespec times[2]); int utimensat(int dirfd, const char* path, const struct timespec times[2], int flags); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/statvfs.h b/libc/include/sys/statvfs.h index 81fb0a55..55862b9e 100644 --- a/libc/include/sys/statvfs.h +++ b/libc/include/sys/statvfs.h @@ -31,12 +31,16 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int fstatvfs(int, struct statvfs*); int fstatvfsat(int, const char* __restrict, struct statvfs* __restrict, int); int statvfs(const char* __restrict, struct statvfs* __restrict); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/syscall.h b/libc/include/sys/syscall.h index 83f5bbe2..206e39d7 100644 --- a/libc/include/sys/syscall.h +++ b/libc/include/sys/syscall.h @@ -76,11 +76,15 @@ SYSCALL_FUNCTION_BODY(syscall_index) \ /* Create a function that performs the system call by injecting the right instructions into the compiler assembly output. Then provide a declaration of the function that looks just like the caller wants it. */ +#ifdef __cplusplus #define DEFINE_SYSCALL(syscall_type, syscall_name, syscall_index, syscall_formals) \ SYSCALL_FUNCTION(syscall_name, syscall_index) \ -__BEGIN_DECLS \ -syscall_type syscall_name syscall_formals; \ -__END_DECLS \ +extern "C" { syscall_type syscall_name syscall_formals; } +#else +#define DEFINE_SYSCALL(syscall_type, syscall_name, syscall_index, syscall_formals) \ +SYSCALL_FUNCTION(syscall_name, syscall_index) \ +syscall_type syscall_name syscall_formals; +#endif /* System call accepting no parameters. */ #define DEFN_SYSCALL0(type, fn, num) \ diff --git a/libc/include/sys/termmode.h b/libc/include/sys/termmode.h index c577eec5..80fc5214 100644 --- a/libc/include/sys/termmode.h +++ b/libc/include/sys/termmode.h @@ -29,11 +29,15 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif int settermmode(int fd, unsigned mode); int gettermmode(int fd, unsigned* mode); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/time.h b/libc/include/sys/time.h index eff8faee..c52bb87d 100644 --- a/libc/include/sys/time.h +++ b/libc/include/sys/time.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __time_t_defined #define __time_t_defined @@ -52,6 +54,8 @@ struct timeval int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/times.h b/libc/include/sys/times.h index 7372e975..b9a6fb5c 100644 --- a/libc/include/sys/times.h +++ b/libc/include/sys/times.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __clock_t_defined #define __clock_t_defined @@ -46,6 +48,8 @@ struct tms clock_t times(struct tms*); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h index f3d0d68c..c86eba5c 100644 --- a/libc/include/sys/types.h +++ b/libc/include/sys/types.h @@ -32,7 +32,9 @@ #include <__/pthread.h> #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __blkcnt_t_defined #define __blkcnt_t_defined @@ -531,6 +533,8 @@ typedef __pthread_t pthread_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/uio.h b/libc/include/sys/uio.h index ec4aa0ce..e27d5f17 100644 --- a/libc/include/sys/uio.h +++ b/libc/include/sys/uio.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __size_t_defined #define __size_t_defined @@ -47,17 +49,23 @@ typedef __ssize_t ssize_t; typedef __off_t off_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif ssize_t readv(int, const struct iovec*, int); ssize_t writev(int, const struct iovec*, int); ssize_t preadv(int, const struct iovec*, int, off_t); ssize_t pwritev(int, const struct iovec*, int, off_t); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/un.h b/libc/include/sys/un.h index 42fcb505..a53b30c1 100644 --- a/libc/include/sys/un.h +++ b/libc/include/sys/un.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __sa_family_t_defined #define __sa_family_t_defined @@ -42,6 +44,8 @@ struct sockaddr_un char sun_path[128 - sizeof(sa_family_t)]; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/utsname.h b/libc/include/sys/utsname.h index b9951561..3a568423 100644 --- a/libc/include/sys/utsname.h +++ b/libc/include/sys/utsname.h @@ -27,7 +27,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define _UTSNAME_LENGTH 65 @@ -46,6 +48,8 @@ struct utsname int uname(struct utsname*); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h index 5ed99414..4af5e861 100644 --- a/libc/include/sys/wait.h +++ b/libc/include/sys/wait.h @@ -31,7 +31,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __pid_t_defined #define __pid_t_defined @@ -42,6 +44,8 @@ pid_t wait(int* stat_loc); /* TODO: int waitid(idtype_t, id_t, siginfo_t*, int); */ pid_t waitpid(pid_t pid, int *stat_loc, int options); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/syslog.h b/libc/include/syslog.h index 32865fc0..8b3edac8 100644 --- a/libc/include/syslog.h +++ b/libc/include/syslog.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define LOG_PRISHIFT 0 #define LOG_PRIBITS 3 @@ -102,6 +104,8 @@ void syslog(int, const char*, ...); __attribute__ ((__format__ (__printf__, 2, 0))) void vsyslog(int, const char*, va_list); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/system-elf.h b/libc/include/system-elf.h index 8df28459..ef70c437 100644 --- a/libc/include/system-elf.h +++ b/libc/include/system-elf.h @@ -31,7 +31,9 @@ #include <__/wordsize.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if __WORDSIZE == 32 typedef Elf32_Half Elf_Half; @@ -89,6 +91,8 @@ typedef Elf64_Lib Elf_Lib; #error "You need to typedef these to the types of your platform." #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/termios.h b/libc/include/termios.h index f32afdc4..3de39d0b 100644 --- a/libc/include/termios.h +++ b/libc/include/termios.h @@ -35,7 +35,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if __USE_SORTIX #ifndef __size_t_defined @@ -58,6 +60,8 @@ int tcgetwincurpos(int, struct wincurpos*); int tcgetwinsize(int, struct winsize*); #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/time.h b/libc/include/time.h index 9584e797..d0085b14 100644 --- a/libc/include/time.h +++ b/libc/include/time.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __clock_t_defined #define __clock_t_defined @@ -85,13 +87,17 @@ struct tm int tm_isdst; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #include #include #if __USE_SORTIX #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef NULL #define __need_NULL @@ -100,10 +106,14 @@ __BEGIN_DECLS #define CLOCKS_PER_SEC 1000000l -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #include #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* getdate_err is omitted, use strptime */ @@ -163,6 +173,8 @@ int timens(struct tmns* tmns); extern char* tzname[2]; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/timespec.h b/libc/include/timespec.h index eea41e79..eb37cd88 100644 --- a/libc/include/timespec.h +++ b/libc/include/timespec.h @@ -33,18 +33,24 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __time_t_defined #define __time_t_defined typedef __time_t time_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif static __inline bool timespec_eq(struct timespec a, struct timespec b) { @@ -104,6 +110,8 @@ struct timespec timespec_canonalize(struct timespec t); struct timespec timespec_add(struct timespec a, struct timespec b); struct timespec timespec_sub(struct timespec a, struct timespec b); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/unistd.h b/libc/include/unistd.h index 7d62398d..bc2f2af8 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -39,7 +39,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* If a POSIX revision was already decided by feature macros. */ #if __USE_POSIX @@ -571,6 +573,8 @@ pid_t tfork(int flags, struct tfork* regs); int truncateat(int dirfd, const char*, off_t); #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/utime.h b/libc/include/utime.h index 68013543..43d72740 100644 --- a/libc/include/utime.h +++ b/libc/include/utime.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __time_t_defined #define __time_t_defined @@ -44,6 +46,8 @@ struct utimbuf int utime(const char* filename, const struct utimbuf* times); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/wchar.h b/libc/include/wchar.h index d8da2966..55354b6f 100644 --- a/libc/include/wchar.h +++ b/libc/include/wchar.h @@ -42,7 +42,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef NULL #define __need_NULL @@ -234,6 +236,8 @@ size_t wcslcpy(wchar_t* __restrict, const wchar_t* __restrict, size_t); /* TODO: wcstoull_l */ #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/include/wctype.h b/libc/include/wctype.h index 9b79fbb6..c9af0664 100644 --- a/libc/include/wctype.h +++ b/libc/include/wctype.h @@ -31,7 +31,9 @@ #include <__/wchar.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #ifndef __wint_t_defined #define __wint_t_defined @@ -97,6 +99,8 @@ wctrans_t wctrans_l(const char *, locale_t); wctype_t wctype_l(const char *, locale_t); #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/stdio/fdio.h b/libc/stdio/fdio.h index cea19e72..5f6d43e2 100644 --- a/libc/stdio/fdio.h +++ b/libc/stdio/fdio.h @@ -34,7 +34,9 @@ #endif #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif struct fdio_state { @@ -52,6 +54,8 @@ int fdio_close(void* user); bool fdio_install_fd(FILE* fp, int fd, const char* mode); bool fdio_install_path(FILE* fp, const char* path, const char* mode); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp index b70ee6e8..1591c9d5 100644 --- a/libc/stdio/stdio.cpp +++ b/libc/stdio/stdio.cpp @@ -118,4 +118,4 @@ FILE* stdin = &__stdin_file; FILE* stdout = &__stdout_file; FILE* stderr = &__stderr_file; -} // extern "C" +} /* extern "C" */ diff --git a/libm/include/__/math.h b/libm/include/__/math.h index f31737a4..b90ea3d7 100644 --- a/libm/include/__/math.h +++ b/libm/include/__/math.h @@ -34,7 +34,9 @@ #include #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if __WORDSIZE == 64 || (defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 0) @@ -61,6 +63,8 @@ typedef long double __double_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libm/include/complex.h b/libm/include/complex.h index 13e1e2d8..8d577776 100644 --- a/libm/include/complex.h +++ b/libm/include/complex.h @@ -18,7 +18,9 @@ #define _Complex_I 1.0fi #define I _Complex_I -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* 7.3.5 Trigonometric functions */ /* 7.3.5.1 The cacos functions */ @@ -117,6 +119,8 @@ double creal(double complex); float crealf(float complex); long double creall(long double complex); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif /* !INCLUDE_COMPLEX_H */ diff --git a/libm/include/fenv.h b/libm/include/fenv.h index 52b3a74d..578f788f 100644 --- a/libm/include/fenv.h +++ b/libm/include/fenv.h @@ -36,7 +36,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* Function prototypes */ int feclearexcept(int); @@ -59,6 +61,8 @@ int fegetexcept(void); #endif /* __USE_SORTIX */ -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif /* ! INCLUDE_FENV_H */ diff --git a/libm/include/ieee754.h b/libm/include/ieee754.h index 77f38a20..8d141013 100644 --- a/libm/include/ieee754.h +++ b/libm/include/ieee754.h @@ -38,7 +38,9 @@ #error "Please add support for the endianness on your platform" #endif -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define SNG_EXPBITS 8 #define SNG_FRACBITS 23 @@ -183,6 +185,8 @@ union ieee754_long_double struct ieee754_float_long_double_nan ieee_nan; }; -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libm/include/ieeefp.h b/libm/include/ieeefp.h index e33eea13..a55af7a2 100644 --- a/libm/include/ieeefp.h +++ b/libm/include/ieeefp.h @@ -16,7 +16,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #if defined(__i386__) || defined(__x86_64__) @@ -61,6 +63,8 @@ fp_except_t fpgetsticky(void); fp_except_t fpsetsticky(fp_except_t); fp_except_t fpresetsticky(fp_except_t); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif /* INCLUDE_IEEEFP_H */ diff --git a/libm/include/math.h b/libm/include/math.h index 316c0020..e1657241 100644 --- a/libm/include/math.h +++ b/libm/include/math.h @@ -41,7 +41,9 @@ #include <__/math.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define __fpmacro_unary_floating(__name, __arg0) \ /* LINTED */ \ @@ -477,6 +479,8 @@ int ilogbl(long double); long double logbl(long double); long double scalbnl(long double, int); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libpthread/include/__/pthread.h b/libpthread/include/__/pthread.h index 2ee38a6e..1e2420ed 100644 --- a/libpthread/include/__/pthread.h +++ b/libpthread/include/__/pthread.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif #define __sortix_libpthread__ 1 @@ -167,6 +169,8 @@ typedef struct pthread* __pthread_t; typedef struct __pthread* __pthread_t; #endif -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libpthread/include/pthread.h b/libpthread/include/pthread.h index 2bd40ab1..bf7cc8be 100644 --- a/libpthread/include/pthread.h +++ b/libpthread/include/pthread.h @@ -43,7 +43,9 @@ #include <__/pthread.h> -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif /* TODO: #define PTHREAD_BARRIER_SERIAL_THREAD */ /* TODO: #define PTHREAD_CANCEL_ASYNCHRONOUS */ @@ -298,6 +300,8 @@ int pthread_setspecific(pthread_key_t, const void*); /* TODO: pthread_spin_unlock */ /* TODO: pthread_testcancel */ -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff --git a/libpthread/include/semaphore.h b/libpthread/include/semaphore.h index 1578bfac..a5bd370d 100644 --- a/libpthread/include/semaphore.h +++ b/libpthread/include/semaphore.h @@ -29,7 +29,9 @@ #include -__BEGIN_DECLS +#ifdef __cplusplus +extern "C" { +#endif typedef struct { @@ -53,6 +55,8 @@ int sem_trywait(sem_t*); /*int sem_unlink(const char*);*/ int sem_wait(sem_t*); -__END_DECLS +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif