Skip to content

Commit

Permalink
Merge pull request OpenEtherCATsociety#15 from alberth/add_docs
Browse files Browse the repository at this point in the history
Add docs, remove trailing whitespace
  • Loading branch information
mheden committed Nov 18, 2015
2 parents 6501580 + 5239968 commit 64d122c
Show file tree
Hide file tree
Showing 67 changed files with 1,697 additions and 1,362 deletions.
30 changes: 15 additions & 15 deletions osal/intime/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int64_t sysfrequency;
static double qpc2usec;

#define USECS_PER_SEC 1000000

int osal_gettimeofday (struct timeval *tv, struct timezone *tz)
{
return gettimeofday (tv, tz);
Expand Down Expand Up @@ -101,24 +101,24 @@ int osal_usleep(uint32 usec)

/* Mutex is not needed when running single threaded */

void osal_mtx_lock(osal_mutex_t * mtx)
{
void osal_mtx_lock(osal_mutex_t * mtx)
{
/* RtWaitForSingleObject((HANDLE)mtx, INFINITE); */
}
void osal_mtx_unlock(osal_mutex_t * mtx)
{
}

void osal_mtx_unlock(osal_mutex_t * mtx)
{
/* RtReleaseMutex((HANDLE)mtx); */
}
int osal_mtx_lock_timeout(osal_mutex_t * mtx, uint32_t time_ms)
{
}

int osal_mtx_lock_timeout(osal_mutex_t * mtx, uint32_t time_ms)
{
/* return RtWaitForSingleObject((HANDLE)mtx, time_ms); */
return 0;
}
osal_mutex_t * osal_mtx_create(void)
{
}

osal_mutex_t * osal_mtx_create(void)
{
/* return (void*)RtCreateMutex(NULL, FALSE, NULL); */
return (void *)0;
}
Expand Down
2 changes: 1 addition & 1 deletion osal/intime/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#ifndef PACKED
#ifdef _MSC_VER
#define PACKED_BEGIN __pragma(pack(push, 1))
#define PACKED
#define PACKED
#define PACKED_END __pragma(pack(pop))
#elif defined(__GNUC__)
#define PACKED_BEGIN
Expand Down
30 changes: 15 additions & 15 deletions osal/linux/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int osal_gettimeofday(struct timeval *tv, struct timezone *tz)
{
struct timespec ts;
int return_value;

/* Use clock_gettime to prevent possible live-lock.
* Gettimeofday uses CLOCK_REALTIME that can get NTP timeadjust.
* If this function preempts timeadjust and it uses vpage it live-locks.
Expand All @@ -85,12 +85,12 @@ ec_timet osal_current_time(void)

void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff)
{
diff->sec = end->sec - start->sec;
diff->usec = end->usec - start->usec;
if (diff->usec < 0) {
--diff->sec;
diff->usec += 1000000;
}
diff->sec = end->sec - start->sec;
diff->usec = end->usec - start->usec;
if (diff->usec < 0) {
--diff->sec;
diff->usec += 1000000;
}
}

void osal_timer_start(osal_timert * self, uint32 timeout_usec)
Expand Down Expand Up @@ -137,12 +137,12 @@ int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
int ret;
pthread_attr_t attr;
pthread_t *threadp;

threadp = thandle;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, stacksize);
ret = pthread_create(threadp, &attr, func, param);
if(ret < 0)
ret = pthread_create(threadp, &attr, func, param);
if(ret < 0)
{
return 0;
}
Expand All @@ -155,24 +155,24 @@ int osal_thread_create_rt(void *thandle, int stacksize, void *func, void *param)
pthread_attr_t attr;
struct sched_param schparam;
pthread_t *threadp;

threadp = thandle;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, stacksize);
ret = pthread_create(threadp, &attr, func, param);
ret = pthread_create(threadp, &attr, func, param);
pthread_attr_destroy(&attr);
if(ret < 0)
if(ret < 0)
{
return 0;
}
memset(&schparam, 0, sizeof(schparam));
schparam.sched_priority = 40;
ret = pthread_setschedparam(*threadp, SCHED_FIFO, &schparam);
if(ret < 0)
if(ret < 0)
{
return 0;
}

return 1;
}

18 changes: 9 additions & 9 deletions osal/win32/inttypes.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// ISO C9x compliant inttypes.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006 Alexander Chemeris
//
//
// 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.
//
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, 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.
//
//
///////////////////////////////////////////////////////////////////////////////

#ifndef _MSC_VER // [
Expand Down
18 changes: 9 additions & 9 deletions osal/win32/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int64_t sysfrequency;
static double qpc2usec;

#define USECS_PER_SEC 1000000

int osal_gettimeofday (struct timeval *tv, struct timezone *tz)
{
int64_t wintime, usecs;
Expand All @@ -61,7 +61,7 @@ int osal_gettimeofday (struct timeval *tv, struct timezone *tz)
usecs = (int64_t)((double)wintime * qpc2usec);
tv->tv_sec = (long)(usecs / 1000000);
tv->tv_usec = (long)(usecs - (tv->tv_sec * 1000000));

return 1;
}

Expand All @@ -78,12 +78,12 @@ ec_timet osal_current_time (void)

void osal_time_diff(ec_timet *start, ec_timet *end, ec_timet *diff)
{
diff->sec = end->sec - start->sec;
diff->usec = end->usec - start->usec;
if (diff->usec < 0) {
--diff->sec;
diff->usec += 1000000;
}
diff->sec = end->sec - start->sec;
diff->usec = end->usec - start->usec;
if (diff->usec < 0) {
--diff->sec;
diff->usec += 1000000;
}
}

void osal_timer_start (osal_timert *self, uint32 timeout_usec)
Expand Down Expand Up @@ -140,7 +140,7 @@ void osal_free(void *ptr)
int osal_thread_create(void **thandle, int stacksize, void *func, void *param)
{
*thandle = CreateThread(NULL, stacksize, func, param, 0, NULL);
if(!thandle)
if(!thandle)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion osal/win32/osal_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
} while (0)

int osal_gettimeofday (struct timeval *tv, struct timezone *tz);

#endif
18 changes: 9 additions & 9 deletions osal/win32/stdint.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
//
// Copyright (c) 2006-2008 Alexander Chemeris
//
//
// 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.
//
//
// 3. The name of the author may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, 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.
//
//
///////////////////////////////////////////////////////////////////////////////

#ifndef _MSC_VER // [
Expand Down
Loading

0 comments on commit 64d122c

Please sign in to comment.