Remove vec_sort macro 32/332/1
authorDamjan Marion <damarion@cisco.com>
Tue, 16 Feb 2016 16:32:34 +0000 (17:32 +0100)
committerDamjan Marion <damarion@cisco.com>
Tue, 16 Feb 2016 16:36:49 +0000 (17:36 +0100)
vec_sort macro was using gcc proprietary nested functions that
require a executable stack and they are considered as unsafe.
Also, nested functions are not supported by other compilers.
vec_sort_with_function() should be used instead.

Change-Id: I05959da63d222ec71c090ba63420b427ce10c79b
Signed-off-by: Damjan Marion <damarion@cisco.com>
vppinfra/vppinfra/vec.h

index 79954f3..0608006 100644 (file)
@@ -888,33 +888,6 @@ do {                                               \
   (_v(cmp) < 0 ? -1 : (_v(cmp) > 0 ? +1 : 0));         \
 })
 
-/**\brief Sort a vector with qsort via user's comparison body
-
-   Example to sort an integer vector:
-     int * int_vec = ...;
-     vec_sort (int_vec, i0, i1, i0[0] - i1[0]);
-
-   WARNING: vec_sort requires an executable stack segment.
-   If at all possible, use vec_sort_with_function () instead.
-
-   @param vec vector to sort
-   @param v0 vector element
-   @param v1 vector element
-   @param body vector comparision expression
-*/
-
-#define vec_sort(vec,v0,v1,body)                                       \
-do {                                                                   \
-  int _vec_sort_compare (const void * _v0,                             \
-                        const void * _v1)                              \
-  {                                                                    \
-    __typeof__ (vec) v0 = (__typeof__ (vec)) _v0;                      \
-    __typeof__ (vec) v1 = (__typeof__ (vec)) _v1;                      \
-    return (int) (body);                                               \
-  }                                                                    \
-  qsort (vec, vec_len (vec), sizeof (vec[0]), _vec_sort_compare);      \
-} while (0)
-
 /** \brief Sort a vector using the supplied element comparison function
 
     @param vec vector to sort