-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improved detection of POSIX #489
Changes from 10 commits
60f10aa
4e10bd3
0a1caee
06b3f01
b3843af
b866e72
b0e670a
3cdfe26
b0f3663
0b37205
f8046b8
ead350b
16ae656
20b089e
5736db2
a35b944
101df4f
2f6ccee
e679741
97a258d
7a8a03c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ | |
/*-************************************* | ||
* Includes | ||
***************************************/ | ||
#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_getTotalFileSize */ | ||
#include "platform.h" /* Compiler options */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It cleary shows what we need |
||
#include "util.h" /* UTIL_GetFileSize, UTIL_getTotalFileSize */ | ||
#include <stdlib.h> /* malloc, free */ | ||
#include <string.h> /* memset */ | ||
#include <stdio.h> /* fprintf, fopen, ftello64 */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Copyright (c) 2016-present, Przemyslaw Skibinski, Yann Collet, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#ifndef PLATFORM_H_MODULE | ||
#define PLATFORM_H_MODULE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you define (in a comment section) what's the objective of this file ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I divided |
||
|
||
#if defined (__cplusplus) | ||
extern "C" { | ||
#endif | ||
|
||
/* ************************************** | ||
* Compiler Options | ||
****************************************/ | ||
#if defined(__INTEL_COMPILER) | ||
# pragma warning(disable : 177) /* disable: message #177: function was declared but never referenced */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, here is one typical issue with defining such compilation flag within That could be a good idea if there was some functions within But now, a user which only includes Disabling a warning flag can be completely legitimate, but it's better done close to, and even limited to, the section where it's needed, and better avoided as a "global setting". If the point here is to disable it for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved it to What about: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Disabling compilation flag should be done on a scope as minimal as possible. |
||
#endif | ||
#if defined(_MSC_VER) | ||
# define _CRT_SECURE_NO_WARNINGS /* Disable some Visual warning messages for fopen, strncpy */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above |
||
# define _CRT_SECURE_NO_DEPRECATE /* VS2005 */ | ||
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ | ||
# if _MSC_VER <= 1800 /* (1800 = Visual Studio 2013) */ | ||
# define snprintf sprintf_s /* snprintf unsupported by Visual <= 2013 */ | ||
# endif | ||
#endif | ||
|
||
|
||
/* ************************************** | ||
* Unix Large Files support (>4GB) | ||
****************************************/ | ||
#if !defined(__LP64__) /* No point defining Large file for 64 bit */ | ||
# define _FILE_OFFSET_BITS 64 /* turn off_t into a 64-bit type for ftello, fseeko */ | ||
# if defined(__sun__) && !defined(_LARGEFILE_SOURCE) /* Sun Solaris 32-bits requires specific definitions */ | ||
# define _LARGEFILE_SOURCE /* fseeko, ftello */ | ||
# elif !defined(_LARGEFILE64_SOURCE) | ||
# define _LARGEFILE64_SOURCE /* off64_t, fseeko64, ftello64 */ | ||
# endif | ||
#endif | ||
|
||
|
||
/* ************************************************************ | ||
* Detect POSIX version | ||
* PLATFORM_POSIX_VERSION = -1 for non-Unix e.g. Windows | ||
* PLATFORM_POSIX_VERSION = 0 for Unix-like non-POSIX | ||
* PLATFORM_POSIX_VERSION >= 1 is equal to found _POSIX_VERSION | ||
***************************************************************/ | ||
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(__midipix__) || defined(__VMS)) | ||
/* UNIX-style OS. ------------------------------------------- */ | ||
# if (defined(__APPLE__) && defined(__MACH__)) || defined(__SVR4) || defined(_AIX) || defined(__hpux) \ | ||
|| defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) /* POSIX.1–2001 (SUSv3) conformant */ | ||
# define PLATFORM_POSIX_VERSION 200112L | ||
# else | ||
# if defined(__linux__) || defined(__linux) | ||
# define _POSIX_C_SOURCE 200112L /* use feature test macro */ | ||
# endif | ||
# include <unistd.h> /* declares _POSIX_VERSION */ | ||
# if defined(_POSIX_VERSION) /* POSIX compliant */ | ||
# define PLATFORM_POSIX_VERSION _POSIX_VERSION | ||
# else | ||
# define PLATFORM_POSIX_VERSION 0 | ||
# endif | ||
# endif | ||
#endif | ||
|
||
#if !defined(PLATFORM_POSIX_VERSION) | ||
# define PLATFORM_POSIX_VERSION -1 | ||
#endif | ||
|
||
|
||
|
||
#if defined (__cplusplus) | ||
} | ||
#endif | ||
|
||
#endif /* PLATFORM_H_MODULE */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of the file makes sense : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of
ZSTDLIB_VISIBILITY
?Why does it help ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
ZSTDLIB_VISIBILITY
is only a helper macro. MinGW needs both__attribute__((visibility("default")))
and__declspec(dll{import, export})
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nick is right.
It solves a bug with
__attribute__ ((visibility ("default")))
and broken DLL compilation with gcc/MinGW