summaryrefslogtreecommitdiff
path: root/src/porting.h
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-04-07 06:13:12 -0400
committerShadowNinja <shadowninja@minetest.net>2015-08-23 22:04:06 -0400
commite4bff8be94c0db4f94e63ad448d0eeb869ccdbbd (patch)
tree7935586e79da5c8c7144e345a8c0fc1cda53beed /src/porting.h
parent6a1047d8c116f793890b63427d53f04ceca95d54 (diff)
downloadminetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.tar.gz
minetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.tar.bz2
minetest-e4bff8be94c0db4f94e63ad448d0eeb869ccdbbd.zip
Clean up threading
* Rename everything. * Strip J prefix. * Change UpperCamelCase functions to lowerCamelCase. * Remove global (!) semaphore count mutex on OSX. * Remove semaphore count getter (unused, unsafe, depended on internal API functions on Windows, and used a hack on OSX). * Add `Atomic<type>`. * Make `Thread` handle thread names. * Add support for C++11 multi-threading. * Combine pthread and win32 sources. * Remove `ThreadStarted` (unused, unneeded). * Move some includes from the headers to the sources. * Move all of `Event` into its header (allows inlining with no new includes). * Make `Event` use `Semaphore` (except on Windows). * Move some porting functions into `Thread`. * Integrate logging with `Thread`. * Add threading test.
Diffstat (limited to 'src/porting.h')
-rw-r--r--src/porting.h89
1 files changed, 0 insertions, 89 deletions
diff --git a/src/porting.h b/src/porting.h
index 2a91fdd06..492c9d3a8 100644
--- a/src/porting.h
+++ b/src/porting.h
@@ -64,28 +64,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define _GNU_SOURCE
#endif
- #include <sched.h>
-
- #ifdef __FreeBSD__
- #include <pthread_np.h>
- typedef cpuset_t cpu_set_t;
- #elif defined(__sun) || defined(sun)
- #include <sys/types.h>
- #include <sys/processor.h>
- #elif defined(_AIX)
- #include <sys/processor.h>
- #elif __APPLE__
- #include <mach/mach_init.h>
- #include <mach/thread_policy.h>
- #endif
-
#define sleep_ms(x) usleep(x*1000)
-
- #define THREAD_PRIORITY_LOWEST 0
- #define THREAD_PRIORITY_BELOW_NORMAL 1
- #define THREAD_PRIORITY_NORMAL 2
- #define THREAD_PRIORITY_ABOVE_NORMAL 3
- #define THREAD_PRIORITY_HIGHEST 4
#endif
#ifdef _MSC_VER
@@ -166,21 +145,6 @@ std::string getDataPath(const char *subpath);
void initializePaths();
/*
- Get number of online processors in the system.
-*/
-int getNumberOfProcessors();
-
-/*
- Set a thread's affinity to a particular processor.
-*/
-bool threadBindToProcessor(threadid_t tid, int pnumber);
-
-/*
- Set a thread's priority.
-*/
-bool threadSetPriority(threadid_t tid, int prio);
-
-/*
Return system information
e.g. "Linux/3.12.7 x86_64"
*/
@@ -311,59 +275,6 @@ inline u32 getDeltaMs(u32 old_time_ms, u32 new_time_ms)
}
}
-#if defined(linux) || defined(__linux)
- #include <sys/prctl.h>
-
- inline void setThreadName(const char *name) {
- /* It would be cleaner to do this with pthread_setname_np,
- * which was added to glibc in version 2.12, but some major
- * distributions are still runing 2.11 and previous versions.
- */
- prctl(PR_SET_NAME, name);
- }
-#elif defined(__FreeBSD__) || defined(__OpenBSD__)
- #include <pthread.h>
- #include <pthread_np.h>
-
- inline void setThreadName(const char *name) {
- pthread_set_name_np(pthread_self(), name);
- }
-#elif defined(__NetBSD__)
- #include <pthread.h>
-
- inline void setThreadName(const char *name) {
- pthread_setname_np(pthread_self(), name);
- }
-#elif defined(_MSC_VER)
- typedef struct tagTHREADNAME_INFO {
- DWORD dwType; // must be 0x1000
- LPCSTR szName; // pointer to name (in user addr space)
- DWORD dwThreadID; // thread ID (-1=caller thread)
- DWORD dwFlags; // reserved for future use, must be zero
- } THREADNAME_INFO;
-
- inline void setThreadName(const char *name) {
- THREADNAME_INFO info;
- info.dwType = 0x1000;
- info.szName = name;
- info.dwThreadID = -1;
- info.dwFlags = 0;
- __try {
- RaiseException(0x406D1388, 0, sizeof(info) / sizeof(DWORD), (ULONG_PTR *) &info);
- } __except (EXCEPTION_CONTINUE_EXECUTION) {}
- }
-#elif defined(__APPLE__)
- #include <pthread.h>
-
- inline void setThreadName(const char *name) {
- pthread_setname_np(name);
- }
-#elif defined(_WIN32) || defined(__GNU__)
- inline void setThreadName(const char* name) {}
-#else
- #warning "Unrecognized platform, thread names will not be available."
- inline void setThreadName(const char* name) {}
-#endif
#ifndef SERVER
float getDisplayDensity();