summaryrefslogtreecommitdiff
path: root/pr/include/md/_macos.h
diff options
context:
space:
mode:
Diffstat (limited to 'pr/include/md/_macos.h')
-rw-r--r--pr/include/md/_macos.h76
1 files changed, 49 insertions, 27 deletions
diff --git a/pr/include/md/_macos.h b/pr/include/md/_macos.h
index f1f0f8aa..90eb07db 100644
--- a/pr/include/md/_macos.h
+++ b/pr/include/md/_macos.h
@@ -65,6 +65,7 @@
#include <Errors.h>
#include <OpenTransport.h>
+#include <DriverServices.h>
#define _PR_HAVE_PEEK_BUFFER
#define _PR_PEEK_BUFFER_MAX (16 * 1024)
@@ -105,7 +106,9 @@ struct _MDSegment {
};
struct _MDCPU {
- PRInt8 notused;
+ AbsoluteTime lastThreadSwitch;
+ AbsoluteTime lastWakeUpProcess;
+ PRBool trackScheduling;
};
typedef struct _MDSocketCallerInfo {
@@ -114,19 +117,22 @@ typedef struct _MDSocketCallerInfo {
} _MDSocketCallerInfo;
struct _MDFileDesc {
- PRInt32 osfd;
- PRBool orderlyDisconnect;
- PRBool readReady;
- PRBool writeReady;
- PRBool exceptReady;
- PRLock * miscLock;
-
- /* Server sockets: listen bit tells the notifier func what to do */
- PRBool doListen;
-
- _MDSocketCallerInfo misc;
- _MDSocketCallerInfo read;
- _MDSocketCallerInfo write;
+ PRInt32 osfd;
+ PRPackedBool orderlyDisconnect;
+ PRPackedBool readReady;
+ PRPackedBool writeReady;
+ PRPackedBool exceptReady;
+ PRLock * miscLock;
+
+ /* Server sockets: listen bit tells the notifier func what to do */
+ PRBool doListen;
+
+ /* stored error for non-blocking connects, as a Unix-style error code */
+ OTReason disconnectError;
+
+ _MDSocketCallerInfo misc;
+ _MDSocketCallerInfo read;
+ _MDSocketCallerInfo write;
};
/*
@@ -172,7 +178,7 @@ extern void _MD_SetIntsOff(PRInt32 ints);
#define _MD_CLEANUP_BEFORE_EXIT()
#define _MD_EXIT(status) exit(status)
#define _MD_INIT_CPUS()
-#define _MD_INIT_RUNNING_CPU(cpu)
+#define _MD_INIT_RUNNING_CPU(cpu) _MD_InitRunningCPU(cpu)
/*
** Process Related definitions
@@ -296,16 +302,20 @@ extern PRStatus _MD_InitThread(PRThread *thread);
** context switch because it might have changed.
*/
/* ResetTimer(); before _PR_Schedule() */
-#define _MD_SWITCH_CONTEXT(_thread) \
- PR_BEGIN_MACRO \
- PR_ASSERT(_thread->no_sched); \
- if (!setjmp(_thread->md.jb)) { \
- _MD_SET_LAST_THREAD(_thread); \
- _PR_Schedule(); \
- } else { \
- PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD()); \
- _MD_LAST_THREAD()->no_sched = 0; \
- } \
+
+
+#define _MD_SWITCH_CONTEXT(_thread) \
+ PR_BEGIN_MACRO \
+ PR_ASSERT(_thread->no_sched); \
+ if (!setjmp(_thread->md.jb)) { \
+ _MD_SET_LAST_THREAD(_thread); \
+ if (_PR_MD_CURRENT_CPU()->md.trackScheduling) \
+ _PR_MD_CURRENT_CPU()->md.lastThreadSwitch = UpTime(); \
+ _PR_Schedule(); \
+ } else { \
+ PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD()); \
+ _MD_LAST_THREAD()->no_sched = 0; \
+ } \
PR_END_MACRO
/*
@@ -473,6 +483,7 @@ extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, c
*/
extern PRStatus _MD_gethostname(char *name, int namelen);
#define _MD_GETHOSTNAME _MD_gethostname
+#define _PR_GET_HOST_ADDR_AS_NAME
/*
XXX _MD_WRITEV, _MD_SHUTDOWN & _MD_GETPEERNAME not done yet!!!
@@ -514,7 +525,6 @@ extern PRStatus _MD_gethostname(char *name, int namelen);
** Time Related definitions
*/
-#define kMacTimerInMiliSecs 8L
#define _MD_GET_INTERVAL _MD_GetInterval
#define _MD_INTERVAL_PER_SEC() PR_MSEC_PER_SEC
#define _MD_INTERVAL_INIT()
@@ -647,7 +657,7 @@ extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
extern void SetLogFileTypeCreator(const char *logFile);
-extern int _MD_mac_get_nonblocking_connect_error(PRInt32 osfd);
+extern int _MD_mac_get_nonblocking_connect_error(PRFileDesc* fd);
/*
@@ -681,6 +691,18 @@ extern void LeaveCritialRegion();
#endif
+
+/*
+ * CPU Idle support
+ */
+
+extern void InitIdleSemaphore();
+extern void TermIdleSemaphore();
+
+extern void WaitOnIdleSemaphore();
+extern void SignalIdleSemaphore();
+
+
/*
* Atomic operations
*/