diff --git a/libretro-common/.gitignore b/libretro-common/.gitignore new file mode 100644 index 0000000000..5761abcfdf --- /dev/null +++ b/libretro-common/.gitignore @@ -0,0 +1 @@ +*.o diff --git a/libretro-common/file/nbio/test/nbio_test b/libretro-common/file/nbio/test/nbio_test new file mode 100755 index 0000000000..2e0203aeca Binary files /dev/null and b/libretro-common/file/nbio/test/nbio_test differ diff --git a/libretro-common/include/compat/getopt.h b/libretro-common/include/compat/getopt.h index ecb7cd55b9..034e6ce307 100644 --- a/libretro-common/include/compat/getopt.h +++ b/libretro-common/include/compat/getopt.h @@ -38,9 +38,9 @@ * prefer to use the actual name. */ #define getopt_long(argc, argv, optstring, longopts, longindex) __getopt_long_retro(argc, argv, optstring, longopts, longindex) -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS struct option { @@ -57,9 +57,8 @@ int getopt_long(int argc, char *argv[], const char *optstring, const struct option *longopts, int *longindex); extern char *optarg; extern int optind, opterr, optopt; -#ifdef __cplusplus -} -#endif + +RETRO_END_DECLS /* If these are variously #defined, then we have bigger problems */ #ifndef no_argument diff --git a/libretro-common/include/compat/posix_string.h b/libretro-common/include/compat/posix_string.h index ac746b74f8..2731231e2a 100644 --- a/libretro-common/include/compat/posix_string.h +++ b/libretro-common/include/compat/posix_string.h @@ -23,13 +23,13 @@ #ifndef __LIBRETRO_SDK_COMPAT_POSIX_STRING_H #define __LIBRETRO_SDK_COMPAT_POSIX_STRING_H +#include + #ifdef _MSC_VER #include #endif -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS #ifdef _WIN32 #undef strtok_r @@ -56,8 +56,6 @@ int isblank(int c); #endif -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/compat/strcasestr.h b/libretro-common/include/compat/strcasestr.h index 0a8d2ca9c1..31dc11bb4f 100644 --- a/libretro-common/include/compat/strcasestr.h +++ b/libretro-common/include/compat/strcasestr.h @@ -30,9 +30,9 @@ #ifndef HAVE_STRCASESTR -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS /* Avoid possible naming collisions during link * since we prefer to use the actual name. */ @@ -40,9 +40,8 @@ extern "C" { char *strcasestr(const char *haystack, const char *needle); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS + #endif #endif diff --git a/libretro-common/include/compat/strl.h b/libretro-common/include/compat/strl.h index 465a75ee18..50d31aa64e 100644 --- a/libretro-common/include/compat/strl.h +++ b/libretro-common/include/compat/strl.h @@ -30,9 +30,9 @@ #include "../../../config.h" #endif -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS #ifdef __MACH__ #ifndef HAVE_STRL @@ -52,9 +52,7 @@ size_t strlcat(char *dest, const char *source, size_t size); #endif -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/dynamic/dylib.h b/libretro-common/include/dynamic/dylib.h index 489a3cde18..7313e9a547 100644 --- a/libretro-common/include/dynamic/dylib.h +++ b/libretro-common/include/dynamic/dylib.h @@ -29,15 +29,15 @@ #include "config.h" #endif +#include + #if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB) #define NEED_DYNAMIC #else #undef NEED_DYNAMIC #endif -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS typedef void *dylib_t; typedef void (*function_t)(void); @@ -66,9 +66,6 @@ char *dylib_error(void); function_t dylib_proc(dylib_t lib, const char *proc); #endif -#ifdef __cplusplus -} -#endif - +RETRO_END_DECLS #endif diff --git a/libretro-common/include/file/config_file.h b/libretro-common/include/file/config_file.h index 81baca941c..344f0931c8 100644 --- a/libretro-common/include/file/config_file.h +++ b/libretro-common/include/file/config_file.h @@ -24,9 +24,9 @@ #ifndef __LIBRETRO_SDK_CONFIG_FILE_H #define __LIBRETRO_SDK_CONFIG_FILE_H -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS #include #include @@ -158,9 +158,7 @@ bool config_file_write(config_file_t *conf, const char *path); * Does not close the file. */ void config_file_dump(config_file_t *conf, FILE *file); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index a5bcfe4809..0ac5ffe89b 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -28,12 +28,12 @@ #include #include +#include + #include #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS /* Order in this enum is equivalent to negative sort order in filelist * (i.e. DIRECTORY is on top of PLAIN_FILE) */ @@ -402,8 +402,6 @@ void fill_pathname_application_path(char *buf, size_t size); **/ bool path_mkdir(const char *dir); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 9ca5cd1412..1f96b81efd 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -18,11 +18,12 @@ #define __RARCH_IMAGE_CONTEXT_H #include + +#include + #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS enum image_process_code { @@ -49,8 +50,6 @@ bool video_texture_image_color_convert(unsigned r_shift, bool video_texture_image_load(struct texture_image *img, const char *path); void video_texture_image_free(struct texture_image *img); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/formats/rbmp.h b/libretro-common/include/formats/rbmp.h index e74d2b196e..4b2a51c1e5 100644 --- a/libretro-common/include/formats/rbmp.h +++ b/libretro-common/include/formats/rbmp.h @@ -23,11 +23,11 @@ #ifndef __LIBRETRO_SDK_FORMAT_RBMP_H__ #define __LIBRETRO_SDK_FORMAT_RBMP_H__ +#include + #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS enum rbmp_source_type { @@ -46,8 +46,6 @@ bool rbmp_save_image( unsigned pitch, enum rbmp_source_type type); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index 7997edadde..6141e0f9db 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -26,12 +26,12 @@ #include #include +#include + #include #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS typedef struct rpng rpng_t; @@ -62,9 +62,7 @@ bool rpng_save_image_bgr24(const char *path, const uint8_t *data, unsigned width, unsigned height, unsigned pitch); #endif -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/formats/rxml.h b/libretro-common/include/formats/rxml.h index ecebefee96..3ee1109601 100644 --- a/libretro-common/include/formats/rxml.h +++ b/libretro-common/include/formats/rxml.h @@ -22,9 +22,9 @@ #ifndef __LIBRETRO_SDK_FORMAT_RXML_H__ #define __LIBRETRO_SDK_FORMAT_RXML_H__ -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS /* Total NIH. Very trivial "XML" implementation for use in RetroArch. * Error checking is minimal. Invalid documents may lead to very @@ -89,9 +89,7 @@ typedef rxml_document_t *xmlDocPtr; #define xmlFreeParserCtxt(ctx) ((void)0) #endif -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/formats/tga.h b/libretro-common/include/formats/tga.h index 807ffcdd08..09e813424a 100644 --- a/libretro-common/include/formats/tga.h +++ b/libretro-common/include/formats/tga.h @@ -26,24 +26,22 @@ #include #include -#include - #ifdef HAVE_CONFIG_H #include "../../config.h" #endif -#ifdef __cplusplus -extern "C" { -#endif +#include + +#include + +RETRO_BEGIN_DECLS bool rtga_image_load_shift(uint8_t *buf, void *data, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/gfx/scaler/filter.h b/libretro-common/include/gfx/scaler/filter.h index e3b43c4ad0..11aa020201 100644 --- a/libretro-common/include/gfx/scaler/filter.h +++ b/libretro-common/include/gfx/scaler/filter.h @@ -23,18 +23,16 @@ #ifndef __LIBRETRO_SDK_SCALER_FILTER_H__ #define __LIBRETRO_SDK_SCALER_FILTER_H__ -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS #include #include bool scaler_gen_filter(struct scaler_ctx *ctx); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/gfx/scaler/scaler.h b/libretro-common/include/gfx/scaler/scaler.h index e4937f7e8a..8a68f92af9 100644 --- a/libretro-common/include/gfx/scaler/scaler.h +++ b/libretro-common/include/gfx/scaler/scaler.h @@ -23,15 +23,15 @@ #ifndef __LIBRETRO_SDK_SCALER_H__ #define __LIBRETRO_SDK_SCALER_H__ -#ifdef __cplusplus -extern "C" { -#endif +#include #include #include #include #include +RETRO_BEGIN_DECLS + #define FILTER_UNITY (1 << 14) enum scaler_pix_fmt @@ -145,9 +145,7 @@ void *scaler_alloc(size_t elem_size, size_t size); **/ void scaler_free(void *ptr); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/glsm/glsm.h b/libretro-common/include/glsm/glsm.h index 940433cd98..9c5ab29181 100644 --- a/libretro-common/include/glsm/glsm.h +++ b/libretro-common/include/glsm/glsm.h @@ -23,13 +23,13 @@ #ifndef LIBRETRO_SDK_GLSM_H #define LIBRETRO_SDK_GLSM_H +#include + #include #include #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS #ifdef HAVE_OPENGLES2 typedef GLfloat GLdouble; @@ -147,8 +147,6 @@ typedef struct glsm_ctx_params bool glsm_ctl(enum glsm_state_ctl state, void *data); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 78553a3728..922d94e986 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -25,9 +25,9 @@ #include -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS /* deprecated old FF-style GL symbols */ #define glTexCoord2f rglTexCoord2f @@ -231,8 +231,6 @@ GLint rglGetAttribLocation(GLuint program, const GLchar *name); void rglDrawBuffers(GLsizei n, const GLenum *bufs); void rglBindVertexArray(GLuint array); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/glsym/rglgen.h b/libretro-common/include/glsym/rglgen.h index a528d30637..bf127f8570 100644 --- a/libretro-common/include/glsym/rglgen.h +++ b/libretro-common/include/glsym/rglgen.h @@ -27,11 +27,11 @@ #include "config.h" #endif +#include + #include "rglgen_headers.h" -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS struct rglgen_sym_map; @@ -41,9 +41,7 @@ void rglgen_resolve_symbols(rglgen_proc_address_t proc); void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc, const struct rglgen_sym_map *map); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/libco.h b/libretro-common/include/libco.h index 5a8b11db45..9925d7e378 100644 --- a/libretro-common/include/libco.h +++ b/libretro-common/include/libco.h @@ -23,6 +23,8 @@ #ifndef LIBCO_H #define LIBCO_H +#include + #ifdef LIBCO_C #ifdef LIBCO_MP #define thread_local __thread @@ -31,9 +33,7 @@ #endif #endif -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS typedef void* cothread_t; @@ -73,9 +73,7 @@ void co_delete(cothread_t cothread); */ void co_switch(cothread_t cothread); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS /* ifndef LIBCO_H */ #endif diff --git a/libretro-common/include/lists/dir_list.h b/libretro-common/include/lists/dir_list.h index bfbda4dda3..2ef8f9ff81 100644 --- a/libretro-common/include/lists/dir_list.h +++ b/libretro-common/include/lists/dir_list.h @@ -23,11 +23,11 @@ #ifndef __LIBRETRO_SDK_DIR_LIST_H #define __LIBRETRO_SDK_DIR_LIST_H +#include + #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS /** * dir_list_new: @@ -63,8 +63,6 @@ void dir_list_sort(struct string_list *list, bool dir_first); **/ void dir_list_free(struct string_list *list); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/lists/file_list.h b/libretro-common/include/lists/file_list.h index d23c2ce3a8..ad616f0e01 100644 --- a/libretro-common/include/lists/file_list.h +++ b/libretro-common/include/lists/file_list.h @@ -23,9 +23,9 @@ #ifndef __LIBRETRO_SDK_FILE_LIST_H__ #define __LIBRETRO_SDK_FILE_LIST_H__ -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS #include #include @@ -117,8 +117,6 @@ void file_list_sort_on_type(file_list_t *list); bool file_list_search(const file_list_t *list, const char *needle, size_t *index); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/lists/string_list.h b/libretro-common/include/lists/string_list.h index 4168116f78..9b3d0e47e8 100644 --- a/libretro-common/include/lists/string_list.h +++ b/libretro-common/include/lists/string_list.h @@ -23,13 +23,13 @@ #ifndef __LIBRETRO_SDK_STRING_LIST_H #define __LIBRETRO_SDK_STRING_LIST_H +#include + #include #include #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS union string_list_elem_attr { @@ -141,8 +141,6 @@ void string_list_join_concat(char *buffer, size_t size, void string_list_set(struct string_list *list, unsigned idx, const char *str); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/memalign.h b/libretro-common/include/memalign.h index a8aef5cbb9..f57baf152c 100644 --- a/libretro-common/include/memalign.h +++ b/libretro-common/include/memalign.h @@ -25,16 +25,14 @@ #include -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS void *memalign_alloc(size_t boundary, size_t size); void memalign_free(void *ptr); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/net/net_http.h b/libretro-common/include/net/net_http.h index 1f1da7f450..bac244e94b 100644 --- a/libretro-common/include/net/net_http.h +++ b/libretro-common/include/net/net_http.h @@ -27,9 +27,9 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS struct http_t; struct http_connection_t; @@ -68,8 +68,6 @@ uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error); /* Cleans up all memory. */ void net_http_delete(struct http_t *state); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/queues/fifo_queue.h b/libretro-common/include/queues/fifo_queue.h index 5b4bb01664..bbb5c0bbef 100644 --- a/libretro-common/include/queues/fifo_queue.h +++ b/libretro-common/include/queues/fifo_queue.h @@ -26,9 +26,9 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS typedef struct fifo_buffer fifo_buffer_t; @@ -46,9 +46,7 @@ size_t fifo_read_avail(fifo_buffer_t *buffer); size_t fifo_write_avail(fifo_buffer_t *buffer); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/queues/message_queue.h b/libretro-common/include/queues/message_queue.h index f006eb38e5..6dadb8961e 100644 --- a/libretro-common/include/queues/message_queue.h +++ b/libretro-common/include/queues/message_queue.h @@ -25,9 +25,9 @@ #include -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS typedef struct msg_queue msg_queue_t; @@ -83,8 +83,6 @@ void msg_queue_clear(msg_queue_t *queue); **/ void msg_queue_free(msg_queue_t *queue); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index 793eb5403a..7fc9e2b039 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -26,9 +26,9 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS enum task_queue_ctl_state { @@ -148,8 +148,6 @@ void task_queue_push_progress(retro_task_t *task); bool task_queue_ctl(enum task_queue_ctl_state state, void *data); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/retro_common_api.h b/libretro-common/include/retro_common_api.h new file mode 100644 index 0000000000..16267231f2 --- /dev/null +++ b/libretro-common/include/retro_common_api.h @@ -0,0 +1,92 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (retro_common_api.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _LIBRETRO_COMMON_RETRO_COMMON_API_H +#define _LIBRETRO_COMMON_RETRO_COMMON_API_H + +/* +This file is designed to normalize the libretro-common compiling environment +for public API headers. This should be leaner than a normal compiling environment, +since it gets #included into other project's sources. +*/ + +/* ------------------------------------ */ + +/* +Ordinarily we want to put #ifdef __cplusplus extern "C" in C library +headers to enable them to get used by c++ sources. +However, we want to support building this library as C++ as well, so a +special technique is called for. +*/ + +#define RETRO_BEGIN_DECLS +#define RETRO_END_DECLS + +#ifdef __cplusplus + +#ifdef CXX_BUILD +/* build wants everything to be built as c++, so no extern "C" */ +#else +#undef RETRO_BEGIN_DECLS +#undef RETRO_END_DECLS +#define RETRO_BEGIN_DECLS extern "C" { +#define RETRO_END_DECLS } +#endif + +#else + +/* header is included by a C source file, so no extern "C" */ + +#endif + +/* +IMO, this non-standard ssize_t should not be used. +However, it's a good example of how to handle something like this. +*/ +#ifdef _MSC_VER +#ifndef HAVE_SSIZE_T +#define HAVE_SSIZE_T +#if defined(_WIN64) +typedef __int64 ssize_t; +#elif defined(_WIN32) +typedef int ssize_t; +#endif +#endif +#endif + +/* +I would like to see retro_inline.h moved in here; possibly boolean too. + +rationale: these are used in public APIs, and it is easier to find problems +and write code that works the first time portably when theyre included uniformly +than to do the analysis from scratch each time you think you need it, for each feature. + +Moreover it helps force you to make hard decisions: if you EVER bring in boolean.h, +then you should pay the price everywhere, so you can see how much grief it will cause. + +Of course, another school of thought is that you should do as little damage as possible +in as few places as possible... +*/ + + +/* _LIBRETRO_COMMON_RETRO_COMMON_API_H */ +#endif \ No newline at end of file diff --git a/libretro-common/include/retro_dirent.h b/libretro-common/include/retro_dirent.h index ca867cb190..65af28d11d 100644 --- a/libretro-common/include/retro_dirent.h +++ b/libretro-common/include/retro_dirent.h @@ -23,11 +23,11 @@ #ifndef __RETRO_DIRENT_H #define __RETRO_DIRENT_H +#include + #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS struct RDIR; @@ -53,8 +53,6 @@ bool retro_dirent_is_dir(struct RDIR *rdir); void retro_closedir(struct RDIR *rdir); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/retro_environment.h b/libretro-common/include/retro_environment.h index 8d4ea17190..fa08ddc5e7 100644 --- a/libretro-common/include/retro_environment.h +++ b/libretro-common/include/retro_environment.h @@ -23,6 +23,14 @@ #ifndef __LIBRETRO_SDK_ENVIRONMENT_H #define __LIBRETRO_SDK_ENVIRONMENT_H +/* +This file is designed to create a normalized environment for compiling +libretro-common's private implementations, or any other sources which might +enjoy use of it's environment (RetroArch for instance). +This should be an elaborately crafted environment so that sources don't +need to be full of platform-specific workarounds. +*/ + #if defined (__cplusplus) #if 0 printf("This is C++, version %d.\n", __cplusplus); @@ -65,4 +73,6 @@ printf("This is C++, version %d.\n", __cplusplus); /* This is not standard C. __STDC__ is not defined. */ #endif + + #endif diff --git a/libretro-common/include/retro_stat.h b/libretro-common/include/retro_stat.h index 37e4348e12..a6d53abfb7 100644 --- a/libretro-common/include/retro_stat.h +++ b/libretro-common/include/retro_stat.h @@ -26,11 +26,11 @@ #include #include +#include + #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS /** * path_is_directory: @@ -58,8 +58,6 @@ int32_t path_get_size(const char *path); **/ bool mkdir_norecurse(const char *dir); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/rthreads/rsemaphore.h b/libretro-common/include/rthreads/rsemaphore.h index 6c0f1a392d..8df8187833 100644 --- a/libretro-common/include/rthreads/rsemaphore.h +++ b/libretro-common/include/rthreads/rsemaphore.h @@ -23,9 +23,9 @@ #ifndef __LIBRETRO_SDK_SEMAPHORE_H #define __LIBRETRO_SDK_SEMAPHORE_H -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS typedef struct ssem ssem_t; @@ -47,8 +47,6 @@ void ssem_wait(ssem_t *semaphore); void ssem_signal(ssem_t *semaphore); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif /* __LIBRETRO_SDK_SEMAPHORE_H */ diff --git a/libretro-common/include/rthreads/rthreads.h b/libretro-common/include/rthreads/rthreads.h index 196af8c276..eb805b6f80 100644 --- a/libretro-common/include/rthreads/rthreads.h +++ b/libretro-common/include/rthreads/rthreads.h @@ -23,14 +23,14 @@ #ifndef __LIBRETRO_SDK_RTHREADS_H__ #define __LIBRETRO_SDK_RTHREADS_H__ +#include + #include #include #include #include -#if defined(__cplusplus) -extern "C" { -#endif +RETRO_BEGIN_DECLS typedef struct sthread sthread_t; typedef struct slock slock_t; @@ -183,8 +183,6 @@ int scond_broadcast(scond_t *cond); **/ void scond_signal(scond_t *cond); -#if defined(__cplusplus) -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index 5fd1aa148e..e0241d6aa6 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -28,12 +28,10 @@ #include -#include +#include #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS typedef struct RFILE RFILE; @@ -70,8 +68,6 @@ int filestream_putc(RFILE *stream, int c); int filestream_get_fd(RFILE *stream); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif diff --git a/libretro-common/include/string/stdstring.h b/libretro-common/include/string/stdstring.h index ecc8666438..6db3b17de8 100644 --- a/libretro-common/include/string/stdstring.h +++ b/libretro-common/include/string/stdstring.h @@ -28,9 +28,9 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif +#include + +RETRO_BEGIN_DECLS bool string_is_empty(const char *data); @@ -45,8 +45,6 @@ char *string_to_lower(char *s); char *string_replace_substring(const char *in, const char *pattern, const char *by); -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif