Browse Source

[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 years ago
parent
commit
afdebdc163

+ 0
- 1
src/drivers/net/ath/ath.h View File

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

+ 0
- 2
src/drivers/net/ath/ath5k/ath5k.h View File

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

+ 0
- 2
src/drivers/net/forcedeth.h View File

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

+ 0
- 2
src/drivers/net/pcnet32.h View File

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

+ 2
- 3
src/drivers/net/rtl818x/rtl8185_rtl8225.c View File

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

+ 0
- 3
src/drivers/net/skge.h View File

65
 #define SUPPORTED_TP			(1 << 7)
65
 #define SUPPORTED_TP			(1 << 7)
66
 #define SUPPORTED_FIBRE			(1 << 10)
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
 #define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \
70
 #define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \

+ 0
- 2
src/drivers/net/tg3/tg3.h View File

3284
 	u16				subsystem_device;
3284
 	u16				subsystem_device;
3285
 };
3285
 };
3286
 
3286
 
3287
-#define ARRAY_SIZE(x) ( sizeof(x) / sizeof((x)[0]) )
3288
-
3289
 #define TG3_TX_RING_SIZE		512
3287
 #define TG3_TX_RING_SIZE		512
3290
 #define TG3_DEF_TX_RING_PENDING		(TG3_TX_RING_SIZE - 1)
3288
 #define TG3_DEF_TX_RING_PENDING		(TG3_TX_RING_SIZE - 1)
3291
 
3289
 

+ 0
- 4
src/drivers/net/vxge/vxge_config.h View File

27
 
27
 
28
 #define WAIT_FACTOR          1
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
 #define VXGE_HW_MAC_MAX_WIRE_PORTS      2
30
 #define VXGE_HW_MAC_MAX_WIRE_PORTS      2
35
 #define VXGE_HW_MAC_MAX_AGGR_PORTS      2
31
 #define VXGE_HW_MAC_MAX_AGGR_PORTS      2
36
 #define VXGE_HW_MAC_MAX_PORTS           3
32
 #define VXGE_HW_MAC_MAX_PORTS           3

+ 7
- 0
src/include/compiler.h View File

655
 #define barrier() __asm__ __volatile__ ( "" : : : "memory" )
655
 #define barrier() __asm__ __volatile__ ( "" : : : "memory" )
656
 #endif /* ASSEMBLY */
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
  * @defgroup licences Licence declarations
666
  * @defgroup licences Licence declarations
660
  *
667
  *

Loading…
Cancel
Save