ports/security/nss/files/patch-lib_freebl_mpi_mpcpucache.c
Jan Beich 36151efcba security/nss: unbreak on powerpc64 after r405494
mpi/mpcpucache.c:728:23: error: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Werror,-Wincompatible-pointer-types]
            &cacheline_size, &clen, NULL, 0) < 0 || !cacheline_size)
                             ^~~~~
/usr/include/sys/sysctl.h:1062:48: note: passing argument to parameter here
int     sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
                                                   ^
PR:		147696 (typo origin)
Reported by:	Mark Millard
2018-10-12 11:50:45 +00:00

43 lines
1 KiB
C

--- lib/freebl/mpi/mpcpucache.c.orig 2018-08-31 12:55:53 UTC
+++ lib/freebl/mpi/mpcpucache.c
@@ -705,6 +705,32 @@ s_mpi_getProcessorLineSize()
#endif
#if defined(__ppc64__)
+
+#if defined(__FreeBSD__)
+#include <sys/stddef.h>
+#include <sys/sysctl.h>
+
+#include <machine/cpu.h>
+#include <machine/md_var.h>
+
+unsigned long
+s_mpi_getProcessorLineSize()
+{
+ static int cacheline_size = 0;
+ static int cachemib[] = { CTL_MACHDEP, CPU_CACHELINE };
+ size_t clen;
+
+ if (cacheline_size > 0)
+ return cacheline_size;
+
+ clen = sizeof(cacheline_size);
+ if (sysctl(cachemib, sizeof(cachemib) / sizeof(cachemib[0]),
+ &cacheline_size, &clen, NULL, 0) < 0 || !cacheline_size)
+ return 128; /* guess */
+
+ return cacheline_size;
+}
+#else
/*
* Sigh, The PPC has some really nice features to help us determine cache
* size, since it had lots of direct control functions to do so. The POWER
@@ -758,6 +784,7 @@ s_mpi_getProcessorLineSize()
}
return 0;
}
+#endif
#define MPI_GET_PROCESSOR_LINE_SIZE_DEFINED 1
#endif