mirror of
https://github.com/godotengine/godot
synced 2024-09-04 21:48:31 +00:00
Unix: Remove now unnecessary I/O defines, cleanup
- `LIBC_FILEIO_ENABLED` wasn't defined anywhere, even in _other platforms_. - `NO_NETWORK` is also never defined. It probably isn't enough anyway to disable network APIs in the current codebase. - `UNIX_SOCKET_UNAVAILABLE` is never defined in this code but used by some other platforms, clarify that. - `NO_STATVFS` can be removed as Android supports it since API level 19, which is our current min SDK level. It's also only used for `DirAccessUnix::get_space_left()` which is anyway overridden by `DirAccessJAndroid::get_space_left()` so it shouldn't make a difference. * Fixed documentation for `DirAccess.get_space_left()`. - `NO_FCNTL` is likely also a remnant of early Android days, in current NDK r23 it seems to be available. Also cleaned up unused `fcntl.h` includes. - `NO_ALLOCA` is never defined, and we use alloca in many places now.
This commit is contained in:
parent
d331b803b8
commit
f501e4f665
|
@ -80,7 +80,7 @@
|
|||
<param index="2" name="chmod_flags" type="int" default="-1" />
|
||||
<description>
|
||||
Copies the [param from] file to the [param to] destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten.
|
||||
If [param chmod_flags] is different than [code]-1[/code], the unix permissions for the destination path will be set to the provided value, if available on the current operating system.
|
||||
If [param chmod_flags] is different than [code]-1[/code], the Unix permissions for the destination path will be set to the provided value, if available on the current operating system.
|
||||
Returns one of the [enum Error] code constants ([code]OK[/code] on success).
|
||||
</description>
|
||||
</method>
|
||||
|
@ -199,7 +199,7 @@
|
|||
<method name="get_space_left">
|
||||
<return type="int" />
|
||||
<description>
|
||||
On UNIX desktop systems, returns the available space on the current directory's disk. On other platforms, this information is not available and the method returns 0 or -1.
|
||||
Returns the available space on the current directory's disk, in bytes. Returns [code]0[/code] if the platform-specific method to query the available space fails.
|
||||
</description>
|
||||
</method>
|
||||
<method name="list_dir_begin">
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "dir_access_unix.h"
|
||||
|
||||
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
#include "core/os/memory.h"
|
||||
#include "core/os/os.h"
|
||||
|
@ -41,10 +41,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef ANDROID_ENABLED
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MNTENT
|
||||
#include <mntent.h>
|
||||
|
@ -475,17 +472,12 @@ Error DirAccessUnix::create_link(String p_source, String p_target) {
|
|||
}
|
||||
|
||||
uint64_t DirAccessUnix::get_space_left() {
|
||||
#ifndef NO_STATVFS
|
||||
struct statvfs vfs;
|
||||
if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (uint64_t)vfs.f_bavail * (uint64_t)vfs.f_frsize;
|
||||
#else
|
||||
// FIXME: Implement this.
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
String DirAccessUnix::get_filesystem_type() const {
|
||||
|
@ -516,4 +508,4 @@ DirAccessUnix::~DirAccessUnix() {
|
|||
list_dir_end();
|
||||
}
|
||||
|
||||
#endif // UNIX_ENABLED || LIBC_FILEIO_ENABLED
|
||||
#endif // UNIX_ENABLED
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#ifndef DIR_ACCESS_UNIX_H
|
||||
#define DIR_ACCESS_UNIX_H
|
||||
|
||||
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
#include "core/io/dir_access.h"
|
||||
|
||||
|
@ -90,6 +90,6 @@ public:
|
|||
~DirAccessUnix();
|
||||
};
|
||||
|
||||
#endif // UNIX_ENABLED || LIBC_FILEIO_ENABLED
|
||||
#endif // UNIX_ENABLED
|
||||
|
||||
#endif // DIR_ACCESS_UNIX_H
|
||||
|
|
|
@ -30,24 +30,20 @@
|
|||
|
||||
#include "file_access_unix.h"
|
||||
|
||||
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "core/string/print_string.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(UNIX_ENABLED)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef ANDROID_ENABLED
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef MSVC
|
||||
#define S_ISREG(m) ((m)&_S_IFREG)
|
||||
#include <io.h>
|
||||
|
@ -56,12 +52,6 @@
|
|||
#define S_ISREG(m) ((m)&S_IFREG)
|
||||
#endif
|
||||
|
||||
#ifndef NO_FCNTL
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
void FileAccessUnix::check_errors() const {
|
||||
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
|
||||
|
||||
|
@ -131,13 +121,8 @@ Error FileAccessUnix::open_internal(const String &p_path, int p_mode_flags) {
|
|||
int fd = fileno(f);
|
||||
|
||||
if (fd != -1) {
|
||||
#if defined(NO_FCNTL)
|
||||
unsigned long par = 0;
|
||||
ioctl(fd, FIOCLEX, &par);
|
||||
#else
|
||||
int opts = fcntl(fd, F_GETFD);
|
||||
fcntl(fd, F_SETFD, opts | FD_CLOEXEC);
|
||||
#endif
|
||||
}
|
||||
|
||||
last_error = OK;
|
||||
|
@ -339,4 +324,4 @@ FileAccessUnix::~FileAccessUnix() {
|
|||
_close();
|
||||
}
|
||||
|
||||
#endif // UNIX_ENABLED || LIBC_FILEIO_ENABLED
|
||||
#endif // UNIX_ENABLED
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
typedef void (*CloseNotificationFunc)(const String &p_file, int p_flags);
|
||||
|
||||
|
@ -86,6 +86,6 @@ public:
|
|||
virtual ~FileAccessUnix();
|
||||
};
|
||||
|
||||
#endif // UNIX_ENABLED || LIBC_FILEIO_ENABLED
|
||||
#endif // UNIX_ENABLED
|
||||
|
||||
#endif // FILE_ACCESS_UNIX_H
|
||||
|
|
|
@ -30,32 +30,30 @@
|
|||
|
||||
#include "net_socket_posix.h"
|
||||
|
||||
// Some proprietary Unix-derived platforms don't expose Unix sockets
|
||||
// so this allows skipping this file to reimplement this API differently.
|
||||
#ifndef UNIX_SOCKET_UNAVAILABLE
|
||||
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <poll.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#ifndef NO_FCNTL
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#ifdef WEB_ENABLED
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
// BSD calls this flag IPV6_JOIN_GROUP
|
||||
#if !defined(IPV6_ADD_MEMBERSHIP) && defined(IPV6_JOIN_GROUP)
|
||||
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
|
||||
|
@ -93,7 +91,7 @@
|
|||
#define SIO_UDP_NETRESET _WSAIOW(IOC_VENDOR, 15)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // UNIX_ENABLED
|
||||
|
||||
size_t NetSocketPosix::_set_addr_storage(struct sockaddr_storage *p_addr, const IPAddress &p_ip, uint16_t p_port, IP::Type p_ip_type) {
|
||||
memset(p_addr, 0, sizeof(struct sockaddr_storage));
|
||||
|
@ -309,14 +307,9 @@ void NetSocketPosix::_set_socket(SOCKET_TYPE p_sock, IP::Type p_ip_type, bool p_
|
|||
void NetSocketPosix::_set_close_exec_enabled(bool p_enabled) {
|
||||
#ifndef WINDOWS_ENABLED
|
||||
// Enable close on exec to avoid sharing with subprocesses. Off by default on Windows.
|
||||
#if defined(NO_FCNTL)
|
||||
unsigned long par = p_enabled ? 1 : 0;
|
||||
SOCK_IOCTL(_sock, FIOCLEX, &par);
|
||||
#else
|
||||
int opts = fcntl(_sock, F_GETFD);
|
||||
fcntl(_sock, F_SETFD, opts | FD_CLOEXEC);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) {
|
||||
|
@ -658,7 +651,7 @@ void NetSocketPosix::set_blocking_enabled(bool p_enabled) {
|
|||
ERR_FAIL_COND(!is_open());
|
||||
|
||||
int ret = 0;
|
||||
#if defined(WINDOWS_ENABLED) || defined(NO_FCNTL)
|
||||
#if defined(WINDOWS_ENABLED)
|
||||
unsigned long par = p_enabled ? 0 : 1;
|
||||
ret = SOCK_IOCTL(_sock, FIONBIO, &par);
|
||||
#else
|
||||
|
@ -781,4 +774,5 @@ Error NetSocketPosix::join_multicast_group(const IPAddress &p_multi_address, Str
|
|||
Error NetSocketPosix::leave_multicast_group(const IPAddress &p_multi_address, String p_if_name) {
|
||||
return _change_multicast_group(p_multi_address, p_if_name, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // UNIX_SOCKET_UNAVAILABLE
|
||||
|
|
|
@ -137,10 +137,8 @@ void OS_Unix::initialize_core() {
|
|||
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
|
||||
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
|
||||
|
||||
#ifndef NO_NETWORK
|
||||
NetSocketPosix::make_default();
|
||||
IPUnix::make_default();
|
||||
#endif
|
||||
|
||||
_setup_clock();
|
||||
}
|
||||
|
@ -170,6 +168,7 @@ Error OS_Unix::get_entropy(uint8_t *r_buffer, int p_bytes) {
|
|||
left -= chunk;
|
||||
ofs += chunk;
|
||||
} while (left > 0);
|
||||
// Define this yourself if you don't want to fall back to /dev/urandom.
|
||||
#elif !defined(NO_URANDOM)
|
||||
int r = open("/dev/urandom", O_RDONLY);
|
||||
ERR_FAIL_COND_V(r < 0, FAILED);
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
virtual String get_stdin_string(bool p_block) override;
|
||||
|
||||
virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override; // Should return cryptographycally-safe random bytes.
|
||||
virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override;
|
||||
|
||||
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) override;
|
||||
virtual Error close_dynamic_library(void *p_library_handle) override;
|
||||
|
|
|
@ -309,39 +309,13 @@ Error DirAccessWindows::remove(String p_path) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
FileType DirAccessWindows::get_file_type(const String& p_file) const {
|
||||
WCHAR real_current_dir_name[2048];
|
||||
GetCurrentDirectoryW(2048, real_current_dir_name);
|
||||
String prev_dir = Strong::utf16((const char16_t *)real_current_dir_name);
|
||||
|
||||
bool worked = SetCurrentDirectoryW((LPCWSTR)(current_dir.utf16().get_data()));
|
||||
|
||||
DWORD attr;
|
||||
if (worked) {
|
||||
WIN32_FILE_ATTRIBUTE_DATA fileInfo;
|
||||
attr = GetFileAttributesExW((LPCWSTR)(p_file.utf16().get_data()), GetFileExInfoStandard, &fileInfo);
|
||||
}
|
||||
|
||||
SetCurrentDirectoryW((LPCWSTR)(prev_dir.utf16().get_data()));
|
||||
|
||||
if (!worked) {
|
||||
return FILE_TYPE_NONE;
|
||||
}
|
||||
|
||||
return (attr & FILE_ATTRIBUTE_DIRECTORY) ? FILE_TYPE_
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
uint64_t DirAccessWindows::get_space_left() {
|
||||
uint64_t bytes = 0;
|
||||
if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//this is either 0 or a value in bytes.
|
||||
// This is either 0 or a value in bytes.
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ def configure(env: "Environment"):
|
|||
"-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing".split()
|
||||
)
|
||||
)
|
||||
env.Append(CPPDEFINES=["NO_STATVFS", "GLES_ENABLED"])
|
||||
env.Append(CPPDEFINES=["GLES_ENABLED"])
|
||||
|
||||
if get_min_sdk_version(env["ndk_platform"]) >= 24:
|
||||
env.Append(CPPDEFINES=[("_FILE_OFFSET_BITS", 64)])
|
||||
|
@ -193,7 +193,7 @@ def configure(env: "Environment"):
|
|||
env.Append(LINKFLAGS="-Wl,-soname,libgodot_android.so")
|
||||
|
||||
env.Prepend(CPPPATH=["#platform/android"])
|
||||
env.Append(CPPDEFINES=["ANDROID_ENABLED", "UNIX_ENABLED", "NO_FCNTL"])
|
||||
env.Append(CPPDEFINES=["ANDROID_ENABLED", "UNIX_ENABLED"])
|
||||
env.Append(LIBS=["OpenSLES", "EGL", "GLESv2", "android", "log", "z", "dl"])
|
||||
|
||||
if env["vulkan"]:
|
||||
|
|
|
@ -49,10 +49,14 @@
|
|||
#include "drivers/gles3/rasterizer_gles3.h"
|
||||
#endif
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
@ -66,17 +70,6 @@
|
|||
#define _NET_WM_STATE_REMOVE 0L // remove/unset property
|
||||
#define _NET_WM_STATE_ADD 1L // add/set property
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//stupid linux.h
|
||||
#ifdef KEY_TAB
|
||||
#undef KEY_TAB
|
||||
#endif
|
||||
|
||||
#undef CursorShape
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
|
|
|
@ -42,12 +42,10 @@
|
|||
#include <mntent.h>
|
||||
#endif
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
|
|
|
@ -31,16 +31,16 @@
|
|||
#ifndef DIR_ACCESS_MACOS_H
|
||||
#define DIR_ACCESS_MACOS_H
|
||||
|
||||
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
#include "core/io/dir_access.h"
|
||||
#include "drivers/unix/dir_access_unix.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "core/io/dir_access.h"
|
||||
#include "drivers/unix/dir_access_unix.h"
|
||||
|
||||
class DirAccessMacOS : public DirAccessUnix {
|
||||
protected:
|
||||
virtual String fix_unicode_name(const char *p_name) const override;
|
||||
|
@ -51,6 +51,6 @@ protected:
|
|||
virtual bool is_hidden(const String &p_name) override;
|
||||
};
|
||||
|
||||
#endif // UNIX ENABLED || LIBC_FILEIO_ENABLED
|
||||
#endif // UNIX ENABLED
|
||||
|
||||
#endif // DIR_ACCESS_MACOS_H
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "dir_access_macos.h"
|
||||
|
||||
#if defined(UNIX_ENABLED) || defined(LIBC_FILEIO_ENABLED)
|
||||
#if defined(UNIX_ENABLED)
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -78,4 +78,4 @@ bool DirAccessMacOS::is_hidden(const String &p_name) {
|
|||
return [hidden boolValue];
|
||||
}
|
||||
|
||||
#endif // UNIX_ENABLED || LIBC_FILEIO_ENABLED
|
||||
#endif // UNIX_ENABLED
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
#include "servers/rendering/renderer_compositor.h"
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@
|
|||
#include "gl_manager_windows.h"
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "drivers/winmidi/midi_driver_winmidi.h"
|
||||
#include "key_mapping_windows.h"
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
#ifdef XAUDIO2_ENABLED
|
||||
#include "drivers/xaudio2/audio_driver_xaudio2.h"
|
||||
#endif
|
||||
|
@ -49,10 +50,10 @@
|
|||
#include "platform/windows/vulkan_context_win.h"
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <shellapi.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
|
|
@ -1466,20 +1466,10 @@ bool Node::is_greater_than(const Node *p_node) const {
|
|||
|
||||
ERR_FAIL_COND_V(data.depth < 0, false);
|
||||
ERR_FAIL_COND_V(p_node->data.depth < 0, false);
|
||||
#ifdef NO_ALLOCA
|
||||
|
||||
Vector<int> this_stack;
|
||||
Vector<int> that_stack;
|
||||
this_stack.resize(data.depth);
|
||||
that_stack.resize(p_node->data.depth);
|
||||
|
||||
#else
|
||||
|
||||
int *this_stack = (int *)alloca(sizeof(int) * data.depth);
|
||||
int *that_stack = (int *)alloca(sizeof(int) * p_node->data.depth);
|
||||
|
||||
#endif
|
||||
|
||||
const Node *n = this;
|
||||
|
||||
int idx = data.depth - 1;
|
||||
|
|
Loading…
Reference in a new issue