SDL_platform.h

I put together a consistent set of platform #defines for the platforms
SDL supports. Can you make sure your platform is listed and detected
properly with this header?

Thanks!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment
-------------- next part --------------
/*
SDL - Simple DirectMedia Layer
Copyright © 1997-2006 Sam Lantinga

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

Sam Lantinga
@slouken

*/

/* Try to get a standard set of platform defines */

#if defined(_AIX)
#undef AIX
#define AIX 1
#endif
#if defined(AMIGA) || defined(__AMIGA) || defined(amigados)
/* FIXME: is this the right test for AmigaOS? /
#undef AMIGA
#define AMIGA 1
#endif
#if defined(BEOS)
#undef BEOS
#define BEOS 1
#endif
#if defined(bsdi) || defined(__bsdi) || defined(bsdi)
#undef BSDI
#define BSDI 1
#endif
#if defined(DREAMCAST)
/
FIXME: is this the right test for Dreamcast? /
#undef DREAMCAST
#define DREAMCAST 1
#endif
#if defined(FreeBSD)
#undef FREEBSD
#define FREEBSD 1
#endif
#if defined(hpux) || defined(__hpux) || defined(hpux)
#undef HPUX
#define HPUX 1
#endif
#if defined(sgi) || defined(__sgi) || defined(sgi) || defined(_SGI_SOURCE)
#undef IRIX
#define IRIX 1
#endif
#if defined(linux) || defined(__linux) || defined(linux)
#undef LINUX
#define LINUX 1
#endif
#if defined(macintosh)
#undef MACOS
#define MACOS 1
#endif
#if defined(GNUC) && (defined(APPLE_CC) || defined(APPLE_CPP))
#undef MACOSX
#define MACOSX 1
#define TARGET_API_MAC_CARBON 1
#endif
#if defined(NetBSD)
#undef NETBSD
#define NETBSD 1
#endif
#if defined(OpenBSD)
#undef OPENBSD
#define OPENBSD 1
#endif
#if defined(OS2)
#undef OS2
#define OS2 1
#endif
#if defined(osf) || defined(__osf) || defined(osf) || defined(_OSF_SOURCE)
#undef OSF
#define OSF 1
#endif
#if defined(QNXNTO)
#undef QNXNTO
#define QNXNTO 1
#endif
#if defined(riscos) || defined(__riscos) || defined(riscos)
#undef RISCOS
#define RISCOS 1
#endif
#if defined(solaris) || defined(__solaris) || defined(solaris)
/
FIXME: is this the right test for Solaris? Check SDL_sunaudio.c */
#undef SOLARIS
#define SOLARIS 1
#endif
#if defined(WIN32) || defined(_WIN32)
#undef WIN32
#define WIN32 1
#endif

I put together a consistent set of platform #defines for the platforms
SDL supports. Can you make sure your platform is listed and detected
properly with this header?

I’m attaching a modified version of testendian.c that should help with
this…

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

-------------- next part --------------

/* Test program to check SDL’s CPU endian detection and byte swapping routines */

#include <stdio.h>

#include “SDL.h”
#include “SDL_endian.h”
#include “SDL_platform.h”

int main(int argc, char *argv[])
{
Uint16 value16 = 0xCDAB;
Uint32 value32 = 0xEFBEADDE;
#if defined(GNUC) && defined(SDL_HAS_64BIT_TYPE)
Uint64 value64 = 0xEFBEADDECDAB3412LL;
#endif

printf("This system is running %s\n",

#if AIX
"AIX"
#elif AMIGA
"AmigaOS"
#elif BEOS
"BeOS"
#elif BSDI
"BSDI"
#elif DREAMCAST
"Dreamcast"
#elif FREEBSD
"FreeBSD"
#elif HPUX
"HP-UX"
#elif IRIX
"Irix"
#elif LINUX
"Linux"
#elif MACOS
"MacOS Classic"
#elif MACOSX
"MacOS X"
#elif NETBSD
"NetBSD"
#elif OPENBSD
"OpenBSD"
#elif OS2
"OS/2"
#elif OSF
"OSF/1"
#elif QNXNTO
"QNX Neutrino"
#elif RISCOS
"RISC OS"
#elif SOLARIS
"Solaris"
#elif WIN32
#ifdef _WIN32_WCE
"Windows CE"
#else
"Windows"
#endif
#else
"an unknown operating system!"
#endif
);

printf("This is a %s endian machine.\n",
	(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16));
printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32));

#if defined(GNUC) && defined(SDL_HAS_64BIT_TYPE)
printf(“Value 64 = 0x%llX, swapped = 0x%llX\n”, value64, SDL_Swap64(value64));
#endif
return(0);
}

_WIN64 could be defined, even though not yet available.

Example of use from Microsoft here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf__w64.asp

Reference here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Kernel_d/hh/Kernel_d/Other_35b13e37-5090-4c37-b2a2-e91621b14f89.xml.asp

AFAIK 64 bit compilers are not really available yet, but it seems
reasonable to guess _WIN64 will be defined when they are.
MS says WIN32 will also be defined, so to detect 32 bit platform
you’d need

#if defined(_WIN32) && !defined(_WIN64)

_WIN32 is also defined on 64 bit machine “for backward
compatibility” …On Tue, 2006-02-21 at 00:51 -0800, Sam Lantinga wrote:


John Skaller
Felix, successor to C++: http://felix.sf.net

AFAIK 64 bit compilers are not really available yet,

Yes they are and have been for years…I used one for the Win64 builds
of UT2004 and ShadowOps.

The latest, free download Platform SDK from Microsoft has both amd64 and
Itanium support (and, to my knowledge, does have _WIN64 defined).

–ryan.

Correct, and MSVC 2005 also has a 64bit compiler (just not the express
version).
As for the check, you don’t need to do defined(_WIN32) && !defined(_WIN64) ,
you just need to check for _WIN64 first, as _WIN32 will likely be defined in
both cases.

–William> ----- Original Message -----

From: icculus@icculus.org (icculus)
To: "A list for developers using the SDL library. (includes SDL-announce)"

Sent: Tuesday, February 21, 2006 4:53 AM
Subject: Re: [SDL] SDL_platform.h

AFAIK 64 bit compilers are not really available yet,

Yes they are and have been for years…I used one for the Win64 builds
of UT2004 and ShadowOps.

The latest, free download Platform SDK from Microsoft has both amd64 and
Itanium support (and, to my knowledge, does have _WIN64 defined).

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Le Tue, 21 Feb 2006 00:51:43 -0800
Sam Lantinga a ?crit:

I put together a consistent set of platform #defines for the platforms
SDL supports. Can you make sure your platform is listed and detected
properly with this header?

  • Is it necessary to redefine a system/compiler defined value to the
    same, like for example BEOS and DREAMCAST ?

  • Is SDL_platform.h meant to be used by applications, or just inside
    the SDL library? Isn’t it a bit weird, knowing that SDL goal is
    precisely to hide system differences. SDL for sure can not cover
    everything system-related, I use some #ifdef system related in the SDL
    progs I wrote.

At last, for the gcc m68k-atari-mint target I develop SDL for, the
symbol MINT is the one used for this target.–
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Sp?cialit?: D?veloppement, jeux

I put together a consistent set of platform #defines for the platforms
SDL supports. Can you make sure your platform is listed and detected
properly with this header?

#if defined(macintosh)
#undef MACOS
#define MACOS 1
#endif
#if defined(GNUC) && (defined(APPLE_CC) || defined(APPLE_CPP))
#undef MACOSX
#define MACOSX 1
#define TARGET_API_MAC_CARBON 1
#endif

For Mac OS X, I’ve never seen APPLE_CPP and I don’t think it
exists (running cpp -E -dM /dev/null). I’m thinking maybe we should
just test for APPLE which I do know exists (unless this is
ambiguous with Mac Classic, in which case maybe we throw in MACH
with the mix). I’m thinking that maybe somebody who runs a different
compiler like the Intel optimizing compiler for OS X or CodeWarrior?
may not get the GNUC and APPLE_CC defines. (I don’t know if
these other compilers export APPLE, but I kind of hope they would
or users make a practice of exporting it themselves.

#if defined(solaris) || defined(__solaris) || defined(solaris)
/* FIXME: is this the right test for Solaris? Check SDL_sunaudio.c */
#undef SOLARIS
#define SOLARIS 1
#endif

Here is my -E -dM dump on Solaris 2.8 under gcc 2.8.1 (I don’t have
the Sun compiler.)
(uname -a: SunOS mercury 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500)

#define GCC_NEW_VARARGS 1
#define __sparc 1
#define svr4 1
#define GNUC_MINOR 8
#define __sun 1
#define sparc 1
#define sun 1
#define __unix 1
#define unix 1
#define __SVR4 1
#define sun 1
#define GNUC 2
#define sparc 1
#define unix 1

-Eric> Date: Tue, 21 Feb 2006 00:51:43 -0800

From: Sam Lantinga
Subject: [SDL] SDL_platform.h

  • Is it necessary to redefine a system/compiler defined value to the
    same, like for example BEOS and DREAMCAST ?

Well, I wanted to be able to do this:
#if BEOS
which will fail if BEOS is defined like this:
#define BEOS

Also, I figured I’d make it explicit which platforms are handled.

  • Is SDL_platform.h meant to be used by applications, or just inside
    the SDL library?

I’m not sure at this point. It’s really there for SDL_config.h.default,
but might be useful for applications that care about the platform they’re
running on.

At last, for the gcc m68k-atari-mint target I develop SDL for, the
symbol MINT is the one used for this target.

What exactly is mint, is that an OS?

Thanks!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

Correct:

“MiNT (“MiNT is Now TOS”) is an alternative operating system (OS)
kernel for the Atari ST computer and its successors which is free
software.”

(From: http://en.wikipedia.org/wiki/MiNT )

Note: I am not an ST user. Never got beyond the 8-bit XL series. ;^)On Wed, Feb 22, 2006 at 05:15:56PM -0800, Sam Lantinga wrote:

At last, for the gcc m68k-atari-mint target I develop SDL for, the
symbol MINT is the one used for this target.

What exactly is mint, is that an OS?


-bill! Tux Paint 2006 wall calendar,
bill at newbreedsoftware.com CDROM, bumper sticker & apparel
http://www.newbreedsoftware.com/ http://www.cafepress.com/newbreedsw

Le Wed, 22 Feb 2006 17:57:33 -0800
Bill Kendrick a ?crit:> On Wed, Feb 22, 2006 at 05:15:56PM -0800, Sam Lantinga wrote:

At last, for the gcc m68k-atari-mint target I develop SDL for, the
symbol MINT is the one used for this target.

What exactly is mint, is that an OS?

Correct:

“MiNT (“MiNT is Now TOS”) is an alternative operating system (OS)
kernel for the Atari ST computer and its successors which is free
software.”

(From: http://en.wikipedia.org/wiki/MiNT )

To be more precise, the Atari ST line of computers as a ROM based OS
(which is TOS), which only do monotasking (a bit like MSDOS), but at
last it has GEM as a GUI. Sources for it have been released under the
GPL: http://sourceforge.net/projects/emutos

MiNT is a disk-loaded multitasking kernel, which has some drivers for
hardware (but not all), some GUI, etc…:
http://sparemint.atariforge.net/sparemint/

So in SDL I have several cases to support:

  • TOS without API support for some hardware -> direct hardware access
  • TOS with API support for hardware -> ok, use that API
  • MiNT with device drivers for hardware X -> ok, use that /dev/stuff
    driver
  • MiNT without device drivers for hardware X -> direct hardware access,
    may be a bit crashy in a multitasking OS.

For example, the pth thread library can not work under TOS, so I must
disable thread support in SDL for it. Also, I can use CD-ROMs via 2
different API: a TOS extension, and the classic /dev/cdrom ioctl. I
wonder if it would be possible in SDL to ‘driverize’ these features,
like audio and video suppotr do, and select one at will inside SDL.

I know this is maybe the only target that would need that, but I am not
afraid to ask.


Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Sp?cialit?: D?veloppement, jeux

Also, I can use CD-ROMs via 2
different API: a TOS extension, and the classic /dev/cdrom ioctl. I
wonder if it would be possible in SDL to ‘driverize’ these features,
like audio and video suppotr do, and select one at will inside SDL.

You’re welcome to submit a patch for it, now that CVS is stable. :slight_smile:

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

For Mac OS X, I’ve never seen APPLE_CPP and I don’t think it
exists (running cpp -E -dM /dev/null).

Actually, I was working off of Apple’s ConditionalMacros.h and the MacOS X
equivalent (I forget the name offhand)

#if defined(solaris) || defined(__solaris) || defined(solaris)
/* FIXME: is this the right test for Solaris? Check SDL_sunaudio.c */
#undef SOLARIS
#define SOLARIS 1
#endif

Here is my -E -dM dump on Solaris 2.8 under gcc 2.8.1 (I don’t have
the Sun compiler.)
(uname -a: SunOS mercury 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500)

I think I can go off of __SVR4, but I’ll try to confirm later with Sun’s
compiler (which I have for Solaris 10)

Thanks!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

With 2.0.3 and the Win RT header include, this unfortunately stops CodeBlocks from compiling a program now, as it has no “winapifamily.h” file…

Hi MrTAToad,

I’m having a bit of trouble getting CodeBlocks up and running on my own system (ld.exe is crashing, for some reason). I was able to see the compiler error though, and here is a possible fix for SDL_platform.h (which should, at least, make SDL_platform.h compile-able): https://www.dropbox.com/s/dm5lto9qlyfc418/SDL_platform.h

I hope this helps.

– David L.

That works fine thanks!

Go ahead and put that change in revision control, David.

Thanks!

–ryan.> On Mar 17, 2014, at 15:33, “MrTAToad” wrote:

That works fine thanks!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ryan C. Gordon wrote:

Go ahead and put that change in revision control, David.

Done, plus buildbot is reporting that everything is still building ok. :slight_smile:

– David L.

Note: This is a reply to an earlier mailing list discussion, eventually
leading to this commit (winapifamily.h related fix) which is now in 2.0.3:

So, first of all, thanks for applying the fix!

I’m afraid that I still get compilations errors with MinGW (mingw32),
though (Yeah, I know MinGW-w64 can be used instead). The toolchain seems
to have no ready copy of winapifamily.h. Originally it occurred to me on
Ubuntu 12.04 with the stock SDL 2.0.3 header, and it is still the case
on Ubuntu 14.04 now.

This is fixed in Mercurial for 2.0.4.
https://hg.libsdl.org/SDL/rev/e217ed463f25On Tue, Apr 29, 2014 at 9:44 AM, NY00123 wrote:

Note: This is a reply to an earlier mailing list discussion, eventually
leading to this commit (winapifamily.h related fix) which is now in 2.0.3:

https://hg.libsdl.org/SDL/rev/a98cd2320e82

So, first of all, thanks for applying the fix!

I’m afraid that I still get compilations errors with MinGW (mingw32),
though (Yeah, I know MinGW-w64 can be used instead). The toolchain seems to
have no ready copy of winapifamily.h. Originally it occurred to me on
Ubuntu 12.04 with the stock SDL 2.0.3 header, and it is still the case on
Ubuntu 14.04 now.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Facepalm looks like I’ve looked at the wrong page somewhere…

Thanks for the confirmation!On 04/29/2014 09:18 PM, Sam Lantinga wrote:

This is fixed in Mercurial for 2.0.4.
https://hg.libsdl.org/SDL/rev/e217ed463f25