src: add loader src description
[openocd.git] / src / helper / jim-eventloop.c
index d53a76db40d9e0db2110670a3c0a52cda4c8d08d..fe2d685bcec9507984eb64052e43a78531fe065f 100644 (file)
@@ -2,25 +2,25 @@
  *
  * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
  * Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
- * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net> 
- * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
+ * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
+ * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
  * Copyright 2008 Andrew Lunn <andrew@lunn.ch>
  * Copyright 2008 Duane Ellis <openocd@duaneellis.com>
  * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>
- * 
+ *
  * The FreeBSD license
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above
  *    copyright notice, this list of conditions and the following
  *    disclaimer in the documentation and/or other materials
  *    provided with the distribution.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
@@ -33,7 +33,7 @@
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * The views and conclusions contained in the software and documentation
  * are those of the authors and should not be interpreted as representing
  * official policies, either expressed or implied, of the Jim Tcl Project.
@@ -52,8 +52,7 @@
 #define __JIM_EVENTLOOP_CORE__
 #ifdef __ECOS
 #include <pkgconf/jimtcl.h>
-#endif
-#ifdef __ECOS
+#include <sys/time.h>
 #include <cyg/jimtcl/jim.h>
 #include <cyg/jimtcl/jim-eventloop.h>
 #else
 #include "jim-eventloop.h"
 #endif
 
-#include "replacements.h"
-
-
-/* --- */
-
 /* File event structure */
 typedef struct Jim_FileEvent {
     void *handle;
-    int mask; /* one of JIM_EVENT_(READABLE|WRITABLE|EXCEPTION) */
+    int mask; /* one of JIM_EVENT_(READABLE | WRITABLE | EXCEPTION) */
     Jim_FileProc *fileProc;
     Jim_EventFinalizerProc *finalizerProc;
     void *clientData;
@@ -96,7 +90,7 @@ typedef struct Jim_EventLoop {
     Jim_TimeEvent *timeEventHead;
 } Jim_EventLoop;
 
-void Jim_CreateFileHandler(Jim_Interp *interp, void *handle, int mask,
+static void Jim_CreateFileHandler(Jim_Interp *interp, void *handle, int mask,
         Jim_FileProc *proc, void *clientData,
         Jim_EventFinalizerProc *finalizerProc)
 {
@@ -115,13 +109,13 @@ void Jim_CreateFileHandler(Jim_Interp *interp, void *handle, int mask,
        // fprintf(stderr,"raus\n");
 }
 
-void Jim_DeleteFileHandler(Jim_Interp *interp, void *handle)
+static void Jim_DeleteFileHandler(Jim_Interp *interp, void *handle)
 {
     Jim_FileEvent *fe, *prev = NULL;
     Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop");
 
     fe = eventLoop->fileEventHead;
-    while(fe) {
+    while (fe) {
         if (fe->handle == handle) {
             if (prev == NULL)
                 eventLoop->fileEventHead = fe->next;
@@ -137,16 +131,6 @@ void Jim_DeleteFileHandler(Jim_Interp *interp, void *handle)
     }
 }
 
-// The same for signals.
-void Jim_CreateSignalHandler(Jim_Interp *interp, int signum, 
-        Jim_FileProc *proc, void *clientData,
-        Jim_EventFinalizerProc *finalizerProc)
-{
-}
-void Jim_DeleteSignalHandler(Jim_Interp *interp, int signum) 
-{
-}
-
 /* That's another part of this extension that needs to be ported
  * to WIN32. */
 static void JimGetTime(long *seconds, long *milliseconds)
@@ -158,7 +142,7 @@ static void JimGetTime(long *seconds, long *milliseconds)
     *milliseconds = tv.tv_usec/1000;
 }
 
-jim_wide Jim_CreateTimeHandler(Jim_Interp *interp, jim_wide milliseconds,
+static jim_wide Jim_CreateTimeHandler(Jim_Interp *interp, jim_wide milliseconds,
         Jim_TimeProc *proc, void *clientData,
         Jim_EventFinalizerProc *finalizerProc)
 {
@@ -187,7 +171,7 @@ jim_wide Jim_CreateTimeHandler(Jim_Interp *interp, jim_wide milliseconds,
     return id;
 }
 
-jim_wide Jim_DeleteTimeHandler(Jim_Interp *interp, jim_wide id)
+static jim_wide Jim_DeleteTimeHandler(Jim_Interp *interp, jim_wide id)
 {
     Jim_TimeEvent *te, *prev = NULL;
     Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop");
@@ -197,9 +181,9 @@ jim_wide Jim_DeleteTimeHandler(Jim_Interp *interp, jim_wide id)
     JimGetTime(&cur_sec, &cur_ms);
 
     te = eventLoop->timeEventHead;
-    if (id >= eventLoop->timeEventNextId) 
+    if (id >= eventLoop->timeEventNextId)
        return -2; /* wrong event ID */
-    while(te) {
+    while (te) {
         if (te->id == id) {
             remain  = (te->when_sec - cur_sec) * 1000;
             remain += (te->when_ms  - cur_ms) ;
@@ -229,7 +213,7 @@ static Jim_TimeEvent *JimSearchNearestTimer(Jim_EventLoop *eventLoop)
     Jim_TimeEvent *te = eventLoop->timeEventHead;
     Jim_TimeEvent *nearest = NULL;
 
-    while(te) {
+    while (te) {
         if (!nearest || te->when_sec < nearest->when_sec ||
                 (te->when_sec == nearest->when_sec &&
                  te->when_ms < nearest->when_ms))
@@ -242,7 +226,7 @@ static Jim_TimeEvent *JimSearchNearestTimer(Jim_EventLoop *eventLoop)
 /* --- POSIX version of Jim_ProcessEvents, for now the only available --- */
 #define JIM_FILE_EVENTS 1
 #define JIM_TIME_EVENTS 2
-#define JIM_ALL_EVENTS (JIM_FILE_EVENTS|JIM_TIME_EVENTS)
+#define JIM_ALL_EVENTS (JIM_FILE_EVENTS | JIM_TIME_EVENTS)
 #define JIM_DONT_WAIT 4
 
 /* Process every pending time event, then every pending file event
@@ -276,7 +260,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
     while (fe != NULL) {
         int fd = fileno((FILE*)fe->handle);
 
-        if (fe->mask & JIM_EVENT_READABLE) 
+        if (fe->mask & JIM_EVENT_READABLE)
                FD_SET(fd, &rfds);
         if (fe->mask & JIM_EVENT_WRITABLE) FD_SET(fd, &wfds);
         if (fe->mask & JIM_EVENT_EXCEPTION) FD_SET(fd, &efds);
@@ -303,7 +287,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
             JimGetTime(&now_sec, &now_ms);
             tvp = &tv;
            dt   = 1000 * (shortest->when_sec - now_sec);
-           dt  += ( shortest->when_ms  - now_ms);
+           dt  += (shortest->when_ms  - now_ms);
             if (dt < 0) {
                dt = 1;
            }
@@ -315,7 +299,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
                // fprintf(stderr,"No Event\n");
         }
 
-        retval = select(maxfd+1, &rfds, &wfds, &efds, tvp);
+        retval = select(maxfd + 1, &rfds, &wfds, &efds, tvp);
         if (retval < 0) {
           switch (errno) {
               case EINTR:   fprintf(stderr,"select EINTR\n"); break;
@@ -324,7 +308,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
           }
        } else if (retval > 0) {
             fe = eventLoop->fileEventHead;
-            while(fe != NULL) {
+            while (fe != NULL) {
                 int fd = fileno((FILE*)fe->handle);
 
                // fprintf(stderr,"fd: %d mask: %02x \n",fd,fe->mask);
@@ -366,7 +350,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
     /* Check time events */
     te = eventLoop->timeEventHead;
     maxId = eventLoop->timeEventNextId-1;
-    while(te) {
+    while (te) {
         long now_sec, now_ms;
         jim_wide id;
 
@@ -397,7 +381,7 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
 }
 /* ---------------------------------------------------------------------- */
 
-void JimELAssocDataDeleProc(Jim_Interp *interp, void *data)
+static void JimELAssocDataDeleProc(Jim_Interp *interp, void *data)
 {
     void *next;
     Jim_FileEvent *fe;
@@ -405,7 +389,7 @@ void JimELAssocDataDeleProc(Jim_Interp *interp, void *data)
     Jim_EventLoop *eventLoop = data;
 
     fe = eventLoop->fileEventHead;
-    while(fe) {
+    while (fe) {
         next = fe->next;
         if (fe->finalizerProc)
             fe->finalizerProc(interp, fe->clientData);
@@ -414,7 +398,7 @@ void JimELAssocDataDeleProc(Jim_Interp *interp, void *data)
     }
 
     te = eventLoop->timeEventHead;
-    while(te) {
+    while (te) {
         next = te->next;
         if (te->finalizerProc)
             te->finalizerProc(interp, te->clientData);
@@ -424,7 +408,7 @@ void JimELAssocDataDeleProc(Jim_Interp *interp, void *data)
     Jim_Free(data);
 }
 
-static int JimELVwaitCommand(Jim_Interp *interp, int argc, 
+static int JimELVwaitCommand(Jim_Interp *interp, int argc,
         Jim_Obj *const *argv)
 {
     Jim_Obj *oldValue;
@@ -452,21 +436,21 @@ static int JimELVwaitCommand(Jim_Interp *interp, int argc,
     return JIM_OK;
 }
 
-void JimAfterTimeHandler(Jim_Interp *interp, void *clientData)
+static void JimAfterTimeHandler(Jim_Interp *interp, void *clientData)
 {
     Jim_Obj *objPtr = clientData;
 
     Jim_EvalObjBackground(interp, objPtr);
 }
 
-void JimAfterTimeEventFinalizer(Jim_Interp *interp, void *clientData)
+static void JimAfterTimeEventFinalizer(Jim_Interp *interp, void *clientData)
 {
     Jim_Obj *objPtr = clientData;
 
     Jim_DecrRefCount(interp, objPtr);
 }
 
-static int JimELAfterCommand(Jim_Interp *interp, int argc, 
+static int JimELAfterCommand(Jim_Interp *interp, int argc,
         Jim_Obj *const *argv)
 {
     jim_wide ms, id;
@@ -503,7 +487,7 @@ static int JimELAfterCommand(Jim_Interp *interp, int argc,
        int tlen ;
        jim_wide remain = 0;
        const char *tok = Jim_GetString(argv[2], &tlen);
-       if ( sscanf(tok,"after#%lld",&id) == 1) {
+       if (sscanf(tok,"after#%" JIM_WIDE_MODIFIER, &id) == 1) {
                remain =  Jim_DeleteTimeHandler(interp, id);
                if (remain > -2)  {
                        Jim_SetResult(interp, Jim_NewIntObj(interp, remain));
@@ -515,7 +499,7 @@ static int JimELAfterCommand(Jim_Interp *interp, int argc,
        }
     default:
        fprintf(stderr,"unserviced option to after %d\n",option);
-    } 
+    }
     return JIM_OK;
 }
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)