StdLib: Fix compiler compatibility issues:
tcp.h: Fix packed structure syntax. cdefs.h is not included so the existing __packed attribute was not properly expanded. Non-GCC compilers were also not handled correctly. Changing to the pack(n) pragma is compatible between all supported compilers. SysCalls.c: The utimes() function has a fixed number of arguments and calls a function that takes a va_list argument. GCC will not allow the va_start, etc., macros to be used in a function with a fixed number of arguments, even though that is valid C. The workaround was to create a worker function for utimes() that takes a variable number of arguments. The worker function then uses the va_* macros. Signed-off-by: darylm503 Reviewed-by: leegrosenbaum git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12977 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -190,11 +190,11 @@ _closeX (int fd, int NewState)
|
||||
if(Fp->RefCount == 1) { // There should be no other users
|
||||
if(! IsDupFd(fd)) {
|
||||
// Only do the close if no one else is using the FileHandle
|
||||
if(Fp->f_iflags & FIF_DELCLOSE) {
|
||||
/* Handle files marked "Delete on Close". */
|
||||
if(Fp->f_ops->fo_delete != NULL) {
|
||||
retval = Fp->f_ops->fo_delete(Fp);
|
||||
}
|
||||
if(Fp->f_iflags & FIF_DELCLOSE) {
|
||||
/* Handle files marked "Delete on Close". */
|
||||
if(Fp->f_ops->fo_delete != NULL) {
|
||||
retval = Fp->f_ops->fo_delete(Fp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
retval = Fp->f_ops->fo_close( Fp);
|
||||
@@ -875,7 +875,7 @@ rmdir(
|
||||
retval = filp->f_ops->fo_rmdir(filp);
|
||||
filp->f_iflags = 0; // Close this FD
|
||||
filp->RefCount = 0; // No one using this FD
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -990,8 +990,8 @@ ioctl(
|
||||
}
|
||||
else {
|
||||
/* All other requests. */
|
||||
retval = filp->f_ops->fo_ioctl(filp, request, argp);
|
||||
}
|
||||
retval = filp->f_ops->fo_ioctl(filp, request, argp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
errno = EBADF;
|
||||
@@ -1195,25 +1195,25 @@ chdir (const char *path)
|
||||
|
||||
/* Old Shell does not support Set Current Dir. */
|
||||
if(gEfiShellProtocol != NULL) {
|
||||
Cwd = ShellGetCurrentDir(NULL);
|
||||
if (Cwd != NULL) {
|
||||
/* We have shell support */
|
||||
UnicodePath = AllocatePool(((AsciiStrLen (path) + 1) * sizeof (CHAR16)));
|
||||
if (UnicodePath == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
AsciiStrToUnicodeStr(path, UnicodePath);
|
||||
Status = gEfiShellProtocol->SetCurDir(NULL, UnicodePath);
|
||||
FreePool(UnicodePath);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Cwd = ShellGetCurrentDir(NULL);
|
||||
if (Cwd != NULL) {
|
||||
/* We have shell support */
|
||||
UnicodePath = AllocatePool(((AsciiStrLen (path) + 1) * sizeof (CHAR16)));
|
||||
if (UnicodePath == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
AsciiStrToUnicodeStr(path, UnicodePath);
|
||||
Status = gEfiShellProtocol->SetCurDir(NULL, UnicodePath);
|
||||
FreePool(UnicodePath);
|
||||
if (EFI_ERROR(Status)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Add here for non-shell */
|
||||
errno = EPERM;
|
||||
return -1;
|
||||
@@ -1229,17 +1229,16 @@ pid_t getpgrp(void)
|
||||
return ((pid_t)(UINTN)(gImageHandle));
|
||||
}
|
||||
|
||||
/** Set file access and modification times.
|
||||
|
||||
@param[in] path
|
||||
@param[in] times
|
||||
|
||||
@return
|
||||
**/
|
||||
/* Internal worker function for utimes.
|
||||
This works around an error produced by GCC when the va_* macros
|
||||
are used within a function with a fixed number of arguments.
|
||||
*/
|
||||
static
|
||||
int
|
||||
utimes(
|
||||
const char *path,
|
||||
const struct timeval *times
|
||||
EFIAPI
|
||||
va_Utimes(
|
||||
const char *path,
|
||||
...
|
||||
)
|
||||
{
|
||||
struct __filedes *filp;
|
||||
@@ -1256,6 +1255,21 @@ utimes(
|
||||
}
|
||||
va_end(ap);
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
/** Set file access and modification times.
|
||||
|
||||
@param[in] path
|
||||
@param[in] times
|
||||
|
||||
@return
|
||||
**/
|
||||
int
|
||||
utimes(
|
||||
const char *path,
|
||||
const struct timeval *times
|
||||
)
|
||||
{
|
||||
return va_Utimes(path, times);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user