Protecting "errno" in case it is not defined per e-mail from Vincent R dated 5:37 AM, October 3, 2009.
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@834 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
2bebcfa23f
commit
0027c2521f
@ -683,7 +683,9 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
/* will return true for VC8 (VC2005) and higher */
|
/* will return true for VC8 (VC2005) and higher */
|
||||||
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
||||||
size_t sLen;
|
size_t sLen;
|
||||||
|
#if HAVE_ERRNO
|
||||||
errno_t err;
|
errno_t err;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( fgState.Initialised )
|
if( fgState.Initialised )
|
||||||
@ -706,7 +708,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
{
|
{
|
||||||
/* will return true for VC8 (VC2005) and higher */
|
/* will return true for VC8 (VC2005) and higher */
|
||||||
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
|
||||||
char* fps = NULL;
|
char* fps = NULL;
|
||||||
err = _dupenv_s( &fps, &sLen, "GLUT_FPS" );
|
err = _dupenv_s( &fps, &sLen, "GLUT_FPS" );
|
||||||
if (err)
|
if (err)
|
||||||
@ -725,13 +727,13 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
fgState.FPSInterval = interval;
|
fgState.FPSInterval = interval;
|
||||||
}
|
}
|
||||||
/* will return true for VC8 (VC2005) and higher */
|
/* will return true for VC8 (VC2005) and higher */
|
||||||
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
|
||||||
free ( fps ); fps = NULL; /* dupenv_s allocates a string that we must free */
|
free ( fps ); fps = NULL; /* dupenv_s allocates a string that we must free */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* will return true for VC8 (VC2005) and higher */
|
/* will return true for VC8 (VC2005) and higher */
|
||||||
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
|
||||||
err = _dupenv_s( &displayName, &sLen, "DISPLAY" );
|
err = _dupenv_s( &displayName, &sLen, "DISPLAY" );
|
||||||
if (err)
|
if (err)
|
||||||
fgError("Error getting DISPLAY environment variable");
|
fgError("Error getting DISPLAY environment variable");
|
||||||
@ -823,7 +825,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
*/
|
*/
|
||||||
fghInitialize( displayName );
|
fghInitialize( displayName );
|
||||||
/* will return true for VC8 (VC2005) and higher */
|
/* will return true for VC8 (VC2005) and higher */
|
||||||
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
|
||||||
free ( displayName ); displayName = NULL; /* dupenv_s allocates a string that we must free */
|
free ( displayName ); displayName = NULL; /* dupenv_s allocates a string that we must free */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -36,7 +36,9 @@
|
|||||||
#include "freeglut_internal.h"
|
#include "freeglut_internal.h"
|
||||||
|
|
||||||
#if TARGET_HOST_POSIX_X11
|
#if TARGET_HOST_POSIX_X11
|
||||||
|
#if HAVE_ERRNO
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -139,7 +141,7 @@ void fgInitialiseInputDevices ( void )
|
|||||||
if( !fgState.InputDevsInitialised )
|
if( !fgState.InputDevsInitialised )
|
||||||
{
|
{
|
||||||
/* will return true for VC8 (VC2005) and higher */
|
/* will return true for VC8 (VC2005) and higher */
|
||||||
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
|
||||||
char *dial_device=NULL;
|
char *dial_device=NULL;
|
||||||
size_t sLen;
|
size_t sLen;
|
||||||
errno_t err = _dupenv_s( &dial_device, &sLen, "GLUT_DIALS_SERIAL" );
|
errno_t err = _dupenv_s( &dial_device, &sLen, "GLUT_DIALS_SERIAL" );
|
||||||
@ -166,7 +168,7 @@ void fgInitialiseInputDevices ( void )
|
|||||||
if ( !dial_device ) return;
|
if ( !dial_device ) return;
|
||||||
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
|
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
|
||||||
/* will return true for VC8 (VC2005) and higher */
|
/* will return true for VC8 (VC2005) and higher */
|
||||||
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 )
|
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
|
||||||
free ( dial_device ); dial_device = NULL; /* dupenv_s allocates a string that we must free */
|
free ( dial_device ); dial_device = NULL; /* dupenv_s allocates a string that we must free */
|
||||||
#endif
|
#endif
|
||||||
serial_putchar(dialbox_port,DIAL_INITIALIZE);
|
serial_putchar(dialbox_port,DIAL_INITIALIZE);
|
||||||
|
@ -75,7 +75,9 @@
|
|||||||
# if HAVE_FCNTL_H
|
# if HAVE_FCNTL_H
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# endif
|
# endif
|
||||||
# include <errno.h>
|
# if HAVE_ERRNO
|
||||||
|
# include <errno.h>
|
||||||
|
# endif
|
||||||
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
# if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||||
/* XXX The below hack is done until freeglut's autoconf is updated. */
|
/* XXX The below hack is done until freeglut's autoconf is updated. */
|
||||||
# define HAVE_USB_JS 1
|
# define HAVE_USB_JS 1
|
||||||
@ -237,12 +239,15 @@ static int fghJoystickFindUSBdev(char *name, char *out, int outlen)
|
|||||||
close(f);
|
close(f);
|
||||||
if (cp)
|
if (cp)
|
||||||
return 1;
|
return 1;
|
||||||
} else if (errno == EACCES) {
|
}
|
||||||
|
#if HAVE_ERRNO
|
||||||
|
else if (errno == EACCES) {
|
||||||
if (!protection_warned) {
|
if (!protection_warned) {
|
||||||
fgWarning ( "Can't open %s for read!", buf );
|
fgWarning ( "Can't open %s for read!", buf );
|
||||||
protection_warned = 1;
|
protection_warned = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -260,7 +265,11 @@ static int fghJoystickInitializeHID(struct os_specific_s *os,
|
|||||||
|
|
||||||
if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
|
if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 )
|
||||||
{
|
{
|
||||||
|
#if HAVE_ERRNO
|
||||||
fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
|
fgWarning ( "error: %s: %s", os->fname, strerror( errno ) );
|
||||||
|
#else
|
||||||
|
fgWarning ( "error: %s", os->fname );
|
||||||
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +279,11 @@ static int fghJoystickInitializeHID(struct os_specific_s *os,
|
|||||||
if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
|
if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0)
|
||||||
{
|
{
|
||||||
/*** XXX {report_id} may not be the right variable? ***/
|
/*** XXX {report_id} may not be the right variable? ***/
|
||||||
|
#if HAVE_ERRNO
|
||||||
fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
|
fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) );
|
||||||
|
#else
|
||||||
|
fgWarning ( "error: %s%d", UHIDDEV, report_id );
|
||||||
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,7 +676,11 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if HAVE_ERRNO
|
||||||
if ( len < 0 && errno != EAGAIN )
|
if ( len < 0 && errno != EAGAIN )
|
||||||
|
#else
|
||||||
|
if ( len < 0 )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
perror( joy->os->fname );
|
perror( joy->os->fname );
|
||||||
joy->error = 1;
|
joy->error = 1;
|
||||||
@ -682,6 +699,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
|
|||||||
|
|
||||||
if ( status != sizeof( struct js_event ) )
|
if ( status != sizeof( struct js_event ) )
|
||||||
{
|
{
|
||||||
|
#if HAVE_ERRNO
|
||||||
if ( errno == EAGAIN )
|
if ( errno == EAGAIN )
|
||||||
{
|
{
|
||||||
/* Use the old values */
|
/* Use the old values */
|
||||||
@ -692,6 +710,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )
|
|||||||
sizeof( float ) * joy->num_axes );
|
sizeof( float ) * joy->num_axes );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fgWarning ( "%s", joy->fname );
|
fgWarning ( "%s", joy->fname );
|
||||||
joy->error = GL_TRUE;
|
joy->error = GL_TRUE;
|
||||||
@ -1298,8 +1317,10 @@ static void fghJoystickOpen( SFG_Joystick* joy )
|
|||||||
|
|
||||||
joy->os->fd = open( joy->os->fname, O_RDONLY | O_NONBLOCK);
|
joy->os->fd = open( joy->os->fname, O_RDONLY | O_NONBLOCK);
|
||||||
|
|
||||||
|
#if HAVE_ERRNO
|
||||||
if( joy->os->fd < 0 && errno == EACCES )
|
if( joy->os->fd < 0 && errno == EACCES )
|
||||||
fgWarning ( "%s exists but is not readable by you", joy->os->fname );
|
fgWarning ( "%s exists but is not readable by you", joy->os->fname );
|
||||||
|
#endif
|
||||||
|
|
||||||
joy->error =( joy->os->fd < 0 );
|
joy->error =( joy->os->fd < 0 );
|
||||||
|
|
||||||
|
@ -27,7 +27,9 @@
|
|||||||
|
|
||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
#include "freeglut_internal.h"
|
#include "freeglut_internal.h"
|
||||||
#include <errno.h>
|
#if HAVE_ERRNO
|
||||||
|
# include <errno.h>
|
||||||
|
#endif
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#if HAVE_VPRINTF
|
#if HAVE_VPRINTF
|
||||||
# define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
|
# define VFPRINTF(s,f,a) vfprintf((s),(f),(a))
|
||||||
@ -471,8 +473,10 @@ static void fghSleepForEvents( void )
|
|||||||
wait.tv_usec = (msec % 1000) * 1000;
|
wait.tv_usec = (msec % 1000) * 1000;
|
||||||
err = select( socket+1, &fdset, NULL, NULL, &wait );
|
err = select( socket+1, &fdset, NULL, NULL, &wait );
|
||||||
|
|
||||||
|
#if HAVE_ERRNO
|
||||||
if( ( -1 == err ) && ( errno != EINTR ) )
|
if( ( -1 == err ) && ( errno != EINTR ) )
|
||||||
fgWarning ( "freeglut select() error: %d", errno );
|
fgWarning ( "freeglut select() error: %d", errno );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#elif TARGET_HOST_MS_WINDOWS
|
#elif TARGET_HOST_MS_WINDOWS
|
||||||
MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT );
|
MsgWaitForMultipleObjects( 0, NULL, FALSE, msec, QS_ALLINPUT );
|
||||||
|
Reference in New Issue
Block a user