Check for non standard eaccess(), use open() otherwise.

This commit is contained in:
Vreixo Formoso 2008-01-27 15:53:48 +01:00
parent 5d9e481dff
commit de338a2603
4 changed files with 54 additions and 17 deletions

View File

@ -45,6 +45,10 @@
<listOptionValue builtIn="false" value="/home/metalpain/Projectos/workspace/nglibisofs"/>
<listOptionValue builtIn="false" value="/home/metalpain/Projectos/workspace/nglibisofs/src"/>
</option>
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.734273601" name="Symbols" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="HAVE_EACCESS=1"/>
<listOptionValue builtIn="false" value="HAVE_TIMEGM=1"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.598770298" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
@ -79,6 +83,7 @@
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
@ -244,7 +249,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="converted.config.2029700129">
<scannerConfigBuildInfo instanceId="converted.config.2029700129.1058518760">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
<buildOutputProvider>
@ -327,7 +332,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="converted.config.2029700129.1058518760">
<scannerConfigBuildInfo instanceId="converted.config.2029700129">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
<buildOutputProvider>
@ -476,6 +481,7 @@
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
@ -641,7 +647,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="converted.config.2029700129">
<scannerConfigBuildInfo instanceId="converted.config.2029700129.1058518760">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
<buildOutputProvider>
@ -724,7 +730,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="converted.config.2029700129.1058518760">
<scannerConfigBuildInfo instanceId="converted.config.2029700129">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
<buildOutputProvider>

View File

@ -16,14 +16,14 @@
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>false</value>
@ -40,25 +40,25 @@
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.environment</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value>check -k</value>
<value>-k</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>

View File

@ -92,17 +92,28 @@ AC_PROG_INSTALL
AC_CHECK_HEADERS()
dnl Use GNU extensions if available
AC_DEFINE(_GNU_SOURCE, 1)
dnl Check for tm_gmtoff field in struct tm
AC_CHECK_MEMBER([struct tm.tm_gmtoff],
[AC_DEFINE(HAVE_TM_GMTOFF, 1,
[Define this if tm structure includes a tm_gmtoff entry.])],
,
[#include <time.h>])
dnl Check if non standard timegm() function is available
AC_CHECK_DECL([timegm],
[AC_DEFINE(HAVE_TIMEGM, 1, [Define this if timegm function is available])],
,
[#include <time.h>])
dnl Check if non standard eaccess() function is available
AC_CHECK_DECL([eaccess],
[AC_DEFINE(HAVE_EACCESS, 1, [Define this if eaccess function is available])],
,
[#include <unistd.h>])
THREAD_LIBS=-lpthread
AC_SUBST(THREAD_LIBS)

View File

@ -22,10 +22,15 @@
#include <locale.h>
#include <langinfo.h>
/* for eaccess, defined in unistd.h */
#define __USE_GNU
#include <unistd.h>
/* if we don't have eaccess, we check file access by openning it */
#ifndef HAVE_EACCESS
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
int int_pow(int base, int power)
{
int result = 1;
@ -1117,7 +1122,22 @@ time_t iso_datetime_read_17(const uint8_t *buf)
*/
int iso_eaccess(const char *path)
{
if (eaccess(path, R_OK) != 0) {
int access;
/* use non standard eaccess when available, open() otherwise */
#ifdef HAVE_EACCESS
access = !eaccess(path, R_OK);
#else
int fd = open(path, O_RDONLY);
if (fd != -1) {
close(fd);
access = 1;
} else {
access = 0;
}
#endif
if (!access) {
int err;
/* error, choose an appropriate return code */