Pārlūkot izejas kodu

[build] Provide common ARRAY_SIZE() definition

Several files define the ARRAY_SIZE() macro as used in Linux.  Provide
a common definition for this in include/compiler.h.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 gadus atpakaļ
vecāks
revīzija
afdebdc163

+ 0
- 1
src/drivers/net/ath/ath.h Parādīt failu

@@ -26,7 +26,6 @@ FILE_LICENCE ( BSD2 );
26 26
 #include <ipxe/net80211.h>
27 27
 
28 28
 /* This block of functions are from kernel.h v3.0.1 */
29
-#define ARRAY_SIZE(arr)		(sizeof(arr) / sizeof((arr)[0]))
30 29
 #define DIV_ROUND_UP(n,d)	(((n) + (d) - 1) / (d))
31 30
 #define BITS_PER_BYTE		8
32 31
 #define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))

+ 0
- 2
src/drivers/net/ath/ath5k/ath5k.h Parādīt failu

@@ -34,8 +34,6 @@ FILE_LICENCE ( MIT );
34 34
 #undef ERRFILE
35 35
 #define ERRFILE ERRFILE_ath5k
36 36
 
37
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
38
-
39 37
 /* RX/TX descriptor hw structs */
40 38
 #include "desc.h"
41 39
 

+ 0
- 2
src/drivers/net/forcedeth.h Parādīt failu

@@ -36,8 +36,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
36 36
 #ifndef _FORCEDETH_H_
37 37
 #define _FORCEDETH_H_
38 38
 
39
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
40
-
41 39
 struct ring_desc {
42 40
 	u32 buf;
43 41
 	u32 flaglen;

+ 0
- 2
src/drivers/net/pcnet32.h Parādīt failu

@@ -23,8 +23,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
23 23
 #ifndef _PCNET32_H_
24 24
 #define _PCNET32_H_
25 25
 
26
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
27
-
28 26
 /*
29 27
  * Set the number of Tx and Rx buffers, using Log_2(# buffers).
30 28
  * Set default values to 16 Tx buffers and 32 Rx buffers.

+ 2
- 3
src/drivers/net/rtl818x/rtl8185_rtl8225.c Parādīt failu

@@ -30,7 +30,6 @@ FILE_LICENCE(GPL2_ONLY);
30 30
 #define RTL8225_ANAPARAM2_OFF	0x840dec11
31 31
 
32 32
 #define min(a,b) (((a)<(b))?(a):(b))
33
-#define ARRAY_SIZE(a) (int)(sizeof(a)/sizeof((a)[0]))
34 33
 
35 34
 static inline void rtl8225_write_phy_ofdm(struct net80211_device *dev,
36 35
 					  u8 addr, u8 data)
@@ -323,7 +322,7 @@ static void rtl8225_rf_set_tx_power(struct net80211_device *dev, int channel)
323 322
 static void rtl8225_rf_init(struct net80211_device *dev)
324 323
 {
325 324
 	struct rtl818x_priv *priv = dev->priv;
326
-	int i;
325
+	unsigned int i;
327 326
 
328 327
 	rtl818x_set_anaparam(priv, RTL8225_ANAPARAM_ON);
329 328
 
@@ -552,7 +551,7 @@ static const u16 rtl8225z2_rxgain[] = {
552 551
 static void rtl8225z2_rf_init(struct net80211_device *dev)
553 552
 {
554 553
 	struct rtl818x_priv *priv = dev->priv;
555
-	int i;
554
+	unsigned int i;
556 555
 
557 556
 	rtl818x_set_anaparam(priv, RTL8225_ANAPARAM_ON);
558 557
 

+ 0
- 3
src/drivers/net/skge.h Parādīt failu

@@ -65,9 +65,6 @@ FILE_LICENCE ( GPL2_ONLY );
65 65
 #define SUPPORTED_TP			(1 << 7)
66 66
 #define SUPPORTED_FIBRE			(1 << 10)
67 67
 
68
-/* from kernel.h */
69
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
70
-
71 68
 /* ----------------------------------- */
72 69
 
73 70
 #define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \

+ 0
- 2
src/drivers/net/tg3/tg3.h Parādīt failu

@@ -3284,8 +3284,6 @@ struct tg3 {
3284 3284
 	u16				subsystem_device;
3285 3285
 };
3286 3286
 
3287
-#define ARRAY_SIZE(x) ( sizeof(x) / sizeof((x)[0]) )
3288
-
3289 3287
 #define TG3_TX_RING_SIZE		512
3290 3288
 #define TG3_DEF_TX_RING_PENDING		(TG3_TX_RING_SIZE - 1)
3291 3289
 

+ 0
- 4
src/drivers/net/vxge/vxge_config.h Parādīt failu

@@ -27,10 +27,6 @@ FILE_LICENCE(GPL2_ONLY);
27 27
 
28 28
 #define WAIT_FACTOR          1
29 29
 
30
-#ifndef ARRAY_SIZE
31
-#define ARRAY_SIZE(a)  (sizeof(a) / sizeof((a)[0]))
32
-#endif
33
-
34 30
 #define VXGE_HW_MAC_MAX_WIRE_PORTS      2
35 31
 #define VXGE_HW_MAC_MAX_AGGR_PORTS      2
36 32
 #define VXGE_HW_MAC_MAX_PORTS           3

+ 7
- 0
src/include/compiler.h Parādīt failu

@@ -655,6 +655,13 @@ char __debug_disable(OBJECT) = ( DBGLVL_MAX & ~DBGLVL_DFLT );
655 655
 #define barrier() __asm__ __volatile__ ( "" : : : "memory" )
656 656
 #endif /* ASSEMBLY */
657 657
 
658
+/**
659
+ * Array size
660
+ */
661
+#ifndef ASSEMBLY
662
+#define ARRAY_SIZE(array) ( sizeof (array) / sizeof ( (array)[0] ) )
663
+#endif /* ASSEMBLY */
664
+
658 665
 /**
659 666
  * @defgroup licences Licence declarations
660 667
  *

Notiek ielāde…
Atcelt
Saglabāt