summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2009-07-29 17:09:55 -0700
committerDmitry Shmidt <dimitrysh@google.com>2009-07-29 17:09:55 -0700
commit899e73ea04542662999c77a0ffa125c3f96bd879 (patch)
tree48cd8bc8428029b93ad83fcbb8143181ba66d4fa
parent6b81e10aa53ed66a9ff0d022c0df5852ad41e9ad (diff)
downloadti-899e73ea04542662999c77a0ffa125c3f96bd879.tar.gz
Fix cross-compile problem of sharing shlist object
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r--lib/shlist.c185
-rw-r--r--lib/shlist.h34
-rw-r--r--sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk3
-rw-r--r--wilink_6_1/wpa_supplicant_lib/Android.mk3
4 files changed, 221 insertions, 4 deletions
diff --git a/lib/shlist.c b/lib/shlist.c
new file mode 100644
index 0000000..44919ef
--- /dev/null
+++ b/lib/shlist.c
@@ -0,0 +1,185 @@
+/*-------------------------------------------------------------------*/
+/* List Functionality */
+/*-------------------------------------------------------------------*/
+/* #define SH_LIST_DEBUG */
+/*-------------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+#include "shlist.h"
+/*-------------------------------------------------------------------*/
+void shListInitList( SHLIST *listPtr )
+{
+ listPtr->data = (void *)0L;
+ listPtr->next = listPtr;
+ listPtr->prev = listPtr;
+}
+
+SHLIST *shListFindItem( SHLIST *head, void *val, shListEqual func )
+{
+ SHLIST *item;
+
+ for(item=head->next;( item != head );item=item->next)
+ if( func ) {
+ if( func( val, item->data ) ) {
+ return( item );
+ }
+ }
+ else {
+ if( item->data == val ) {
+ return( item );
+ }
+ }
+ return( NULL );
+}
+
+SHLIST *shListGetLastItem( SHLIST *head )
+{
+ if( head->prev != head )
+ return( head->prev );
+ return( NULL );
+}
+
+SHLIST *shListGetFirstItem( SHLIST *head )
+{
+ if( head->next != head )
+ return( head->next );
+ return( NULL );
+}
+
+SHLIST *shListGetNItem( SHLIST *head, unsigned long num )
+{
+ SHLIST *item;
+ unsigned long i;
+
+ for(i=0,item=head->next;( (i < num) && (item != head) );i++,item=item->next);
+ if( item != head )
+ return( item );
+ return( NULL );
+}
+
+SHLIST *shListGetNextItem( SHLIST *head, SHLIST *item )
+{
+ if( item == NULL )
+ return( NULL );
+ if( item->next != head )
+ return( item->next );
+ return( NULL );
+}
+
+SHLIST *shListGetPrevItem( SHLIST *head, SHLIST *item )
+{
+ if( item == NULL )
+ return( NULL );
+ if( item->prev != head )
+ return( item->prev );
+ return( NULL );
+}
+
+void shListDelItem( SHLIST *head, SHLIST *item, shListFree func )
+{
+ if( item == NULL )
+ return;
+#ifdef SH_LIST_DEBUG
+ fprintf(stderr, "Del %lx\n", (unsigned long)(item->data));
+#endif
+ (item->prev)->next = item->next;
+ (item->next)->prev = item->prev;
+ if( func && item->data ) {
+ func( (void *)(item->data) );
+ }
+ free( item );
+ head->data = (void *)((unsigned long)(head->data) - 1);
+}
+
+void shListInsFirstItem( SHLIST *head, void *val )
+{ /* Insert to the beginning of the list */
+ SHLIST *item;
+
+ item = (SHLIST *)malloc( sizeof(SHLIST) );
+ if( item == NULL )
+ return;
+ item->data = val;
+ item->next = head->next;
+ item->prev = head;
+ (head->next)->prev = item;
+ head->next = item;
+#ifdef SH_LIST_DEBUG
+ fprintf(stderr, "Ins First %lx\n", (unsigned long)(item->data));
+#endif
+ head->data = (void *)((unsigned long)(head->data) + 1);
+}
+
+void shListInsLastItem( SHLIST *head, void *val )
+{ /* Insert to the end of the list */
+ SHLIST *item;
+
+ item = (SHLIST *)malloc( sizeof(SHLIST) );
+ if( item == NULL )
+ return;
+ item->data = val;
+ item->next = head;
+ item->prev = head->prev;
+ (head->prev)->next = item;
+ head->prev = item;
+#ifdef SH_LIST_DEBUG
+ fprintf(stderr, "Ins Last %lx\n", (unsigned long)(item->data));
+#endif
+ head->data = (void *)((unsigned long)(head->data) + 1);
+}
+
+void shListInsBeforeItem( SHLIST *head, void *val, void *etal,
+ shListCmp func )
+{
+ SHLIST *item, *iptr;
+
+ if( func == NULL )
+ shListInsFirstItem( head, val );
+ else {
+ item = (SHLIST *)malloc( sizeof(SHLIST) );
+ if( item == NULL )
+ return;
+ item->data = val;
+ for(iptr=head->next;( iptr != head );iptr=iptr->next)
+ if( func( val, iptr->data, etal ) )
+ break;
+ item->next = iptr;
+ item->prev = iptr->prev;
+ (iptr->prev)->next = item;
+ iptr->prev = item;
+#ifdef SH_LIST_DEBUG
+ fprintf(stderr, "Ins Before %lx\n", (unsigned long)(item->data));
+#endif
+ head->data = (void *)((unsigned long)(head->data) + 1);
+ }
+}
+
+void shListDelAllItems( SHLIST *head, shListFree func )
+{
+ SHLIST *item;
+
+ for(item=head->next;( item != head );) {
+ shListDelItem( head, item, func );
+ item = head->next;
+ }
+ head->data = (void *)0L;
+}
+
+void shListPrintAllItems( SHLIST *head, shListPrint func )
+{
+#ifdef SH_LIST_DEBUG
+ SHLIST *item;
+
+ for(item=head->next;( item != head );item=item->next)
+ if( func ) {
+ func(item->data);
+ }
+ else {
+ fprintf(stderr, "Item: %lx\n",(unsigned long)(item->data));
+ }
+#endif
+}
+
+unsigned long shListGetCount( SHLIST *head )
+{
+ return( (unsigned long)(head->data) );
+}
diff --git a/lib/shlist.h b/lib/shlist.h
new file mode 100644
index 0000000..0a9b07b
--- /dev/null
+++ b/lib/shlist.h
@@ -0,0 +1,34 @@
+/*-------------------------------------------------------------------*/
+/* List Functionality */
+/*-------------------------------------------------------------------*/
+#ifndef _SHLIST_H_
+#define _SHLIST_H_
+
+typedef struct SHLIST_STRUC {
+ void *data;
+ struct SHLIST_STRUC *next;
+ struct SHLIST_STRUC *prev;
+} SHLIST;
+
+typedef int (*shListCmp)( void *valo, void *valn, void *etalon );
+typedef int (*shListPrint)( void *val );
+typedef void (*shListFree)( void *val );
+typedef int (*shListEqual)( void *val, void *idata );
+
+void shListInitList( SHLIST *listPtr );
+SHLIST *shListFindItem( SHLIST *head, void *val, shListEqual func );
+SHLIST *shListGetFirstItem( SHLIST *head );
+SHLIST *shListGetNItem( SHLIST *head, unsigned long num );
+SHLIST *shListGetLastItem( SHLIST *head );
+SHLIST *shListGetNextItem( SHLIST *head, SHLIST *item );
+SHLIST *shListGetPrevItem( SHLIST *head, SHLIST *item );
+void shListDelItem( SHLIST *head, SHLIST *item, shListFree func );
+void shListInsFirstItem( SHLIST *head, void *val );
+void shListInsBeforeItem( SHLIST *head, void *val, void *etalon,
+ shListCmp func );
+void shListInsLastItem( SHLIST *head, void *val );
+void shListDelAllItems( SHLIST *head, shListFree func );
+void shListPrintAllItems( SHLIST *head, shListPrint func );
+unsigned long shListGetCount( SHLIST *head );
+
+#endif
diff --git a/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk b/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk
index db60e6f..7f5a5cb 100644
--- a/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk
+++ b/sta_dk_4_0_4_32/wpa_supplicant_lib/Android.mk
@@ -126,14 +126,13 @@ INCLUDES = $(COMMON)/inc \
$(CUDK_ROOT)/UtilityAdapter \
external/openssl/include \
external/wpa_supplicant \
- system/core/adb \
$(DK_ROOT)/../lib
L_CFLAGS += -DCONFIG_DRIVER_CUSTOM -DHOST_COMPILE
ifeq ($(notdir $(BOARD_WLAN_TI_STA_DK_ROOT)),sta_dk_5_0_0_94)
L_CFLAGS += -DSTA_DK_VER_5_0_0_94
endif
-OBJS = driver_ti.c $(LIB)/scanmerge.c ../../../../core/adb/shlist.c
+OBJS = driver_ti.c $(LIB)/scanmerge.c $(LIB)/shlist.c
ifdef CONFIG_NO_STDOUT_DEBUG
L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
diff --git a/wilink_6_1/wpa_supplicant_lib/Android.mk b/wilink_6_1/wpa_supplicant_lib/Android.mk
index 39e37bc..6d737ef 100644
--- a/wilink_6_1/wpa_supplicant_lib/Android.mk
+++ b/wilink_6_1/wpa_supplicant_lib/Android.mk
@@ -55,11 +55,10 @@ INCLUDES = $(STAD)/Export_Inc \
$(CUDK)/os/common/inc \
external/openssl/include \
external/wpa_supplicant \
- system/core/adb \
$(DK_ROOT)/../lib
L_CFLAGS += -DCONFIG_DRIVER_CUSTOM -DHOST_COMPILE -D__BYTE_ORDER_LITTLE_ENDIAN
-OBJS = driver_ti.c $(LIB)/scanmerge.c ../../../../core/adb/shlist.c
+OBJS = driver_ti.c $(LIB)/scanmerge.c $(LIB)/shlist.c
ifdef CONFIG_NO_STDOUT_DEBUG
L_CFLAGS += -DCONFIG_NO_STDOUT_DEBUG