Skip to content

Commit

Permalink
Merge pull request #264 from rtucker/win-mingw-fixes-inttypes
Browse files Browse the repository at this point in the history
Support Windows builds with MinGW
  • Loading branch information
jynik committed Jun 21, 2014
2 parents d685097 + c9f3945 commit 1534077
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion debian/copyright
Expand Up @@ -122,7 +122,7 @@ License: BSD-2-clause
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Files: host/common/include/windows/inttypes.h Files: host/common/include/windows/inttypes_msvc.h
Copyright: 2006-2013 Alexander Chemeris Copyright: 2006-2013 Alexander Chemeris
Comment: Not used in building Debian packages Comment: Not used in building Debian packages
License: BSD-3-clause License: BSD-3-clause
Expand Down
39 changes: 25 additions & 14 deletions host/common/include/host_config.h.in
Expand Up @@ -152,24 +152,28 @@
#elif BLADERF_OS_WINDOWS #elif BLADERF_OS_WINDOWS


/* Rename a few functions and types */ /* Rename a few functions and types */
#include <Windows.h> #include <windows.h>
#define strtok_r strtok_s
#define strtoull _strtoui64
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define fileno _fileno
#define strdup _strdup
#define usleep(x) Sleep((x+999)/1000) #define usleep(x) Sleep((x+999)/1000)


/* Changes specific to Microsoft Visual Studio and its C89-compliant ways */
#if _MSC_VER
# define strtok_r strtok_s
# define strtoull _strtoui64
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
# define fileno _fileno
# define strdup _strdup

/* ssize_t lives elsewhere */ /* ssize_t lives elsewhere */
#include <BaseTsd.h> # include <BaseTsd.h>
#define ssize_t SSIZE_T # define ssize_t SSIZE_T


/* With msvc, inline is only available for C++. Otherwise we need to use __inline: /* With msvc, inline is only available for C++. Otherwise we need to use __inline:
* http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx */ * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx */
#define inline __inline # define inline __inline
#endif // _MSC_VER


#endif #endif


Expand All @@ -184,10 +188,17 @@
* Here's a sample regexep you could use in vim to clean these up in your code: * Here's a sample regexep you could use in vim to clean these up in your code:
* @\(\s\+\)\(\.[a-zA-Z0-9_]\+\)\s*=\s*\([a-zA-Z0-9_]\+\)\(,\)\?@\1FIELD_INIT(\2,\3)\4@gc * @\(\s\+\)\(\.[a-zA-Z0-9_]\+\)\s*=\s*\([a-zA-Z0-9_]\+\)\(,\)\?@\1FIELD_INIT(\2,\3)\4@gc
*/ */
#if BLADERF_OS_WINDOWS #if _MSC_VER
# define FIELD_INIT(field, ...) __VA_ARGS__ # define FIELD_INIT(field, ...) __VA_ARGS__
#else #else
# define FIELD_INIT(field, ...) field = __VA_ARGS__ # define FIELD_INIT(field, ...) field = __VA_ARGS__
#endif #endif // _MSC_VER

/* MSVC doesn't have inttypes.h. We'll use a local version for this environment. */
#if _MSC_VER
# include <inttypes_msvc.h>
#else
# include <inttypes.h>
#endif // _MSC_VER


#endif #endif
File renamed without changes.
1 change: 0 additions & 1 deletion host/libraries/libbladeRF/src/file_ops.c
Expand Up @@ -25,7 +25,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h>
#include <libbladeRF.h> #include <libbladeRF.h>
#include "host_config.h" #include "host_config.h"
#include "file_ops.h" #include "file_ops.h"
Expand Down
2 changes: 1 addition & 1 deletion host/libraries/libbladeRF/src/si5338.c
Expand Up @@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <string.h> #include <string.h>
#include <inttypes.h>
#include "rel_assert.h" #include "rel_assert.h"


#include "libbladeRF.h" #include "libbladeRF.h"
#include "host_config.h"
#include "bladerf_priv.h" #include "bladerf_priv.h"
#include "log.h" #include "log.h"


Expand Down
3 changes: 2 additions & 1 deletion host/utilities/bladeRF-cli/src/cmd/flash_image.c
Expand Up @@ -23,9 +23,10 @@
#include <stdio.h> #include <stdio.h>
#include <limits.h> #include <limits.h>
#include <time.h> #include <time.h>
#include <inttypes.h>
#include <libbladeRF.h> #include <libbladeRF.h>


#include "host_config.h"
#include "cmd.h" #include "cmd.h"
#include "common.h" #include "common.h"
#include "conversions.h" #include "conversions.h"
Expand Down
2 changes: 1 addition & 1 deletion host/utilities/bladeRF-cli/src/cmd/printset.c
Expand Up @@ -20,7 +20,7 @@
#include <limits.h> #include <limits.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <inttypes.h> #include "host_config.h"
#include "cmd.h" #include "cmd.h"
#include "conversions.h" #include "conversions.h"


Expand Down
1 change: 0 additions & 1 deletion host/utilities/bladeRF-cli/src/cmd/rx.c
Expand Up @@ -25,7 +25,6 @@
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <inttypes.h>


#include "rel_assert.h" #include "rel_assert.h"
#include "host_config.h" #include "host_config.h"
Expand Down
2 changes: 1 addition & 1 deletion host/utilities/bladeRF-cli/src/cmd/rxtx.c
Expand Up @@ -21,9 +21,9 @@
#include <limits.h> #include <limits.h>
#include <pthread.h> #include <pthread.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h>


#include "host_config.h" #include "host_config.h"

#if BLADERF_OS_WINDOWS || BLADERF_OS_OSX #if BLADERF_OS_WINDOWS || BLADERF_OS_OSX
#include "clock_gettime.h" #include "clock_gettime.h"
#else #else
Expand Down

0 comments on commit 1534077

Please sign in to comment.