Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/bouyer-socketcan]: src/usr.sbin/bta2dpd/sbc_crc-gen 767



details:   https://anonhg.NetBSD.org/src/rev/4b0758b4a31e
branches:  bouyer-socketcan
changeset: 820819:4b0758b4a31e
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 30 15:56:45 2017 +0000

description:
767

diffstat:

 usr.sbin/bta2dpd/sbc_crc-gen/sbc_crc.c |  69 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diffs (73 lines):

diff -r 06f1799ac25a -r 4b0758b4a31e usr.sbin/bta2dpd/sbc_crc-gen/sbc_crc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/bta2dpd/sbc_crc-gen/sbc_crc.c    Mon Jan 30 15:56:45 2017 +0000
@@ -0,0 +1,69 @@
+/* $NetBSD: sbc_crc.c,v 1.3.4.2 2017/01/30 15:56:45 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
+ * All rights reserved.
+ *
+ *             This software is dedicated to the memory of -
+ *        Baron James Anlezark (Barry) - 1 Jan 1949 - 13 May 2012.
+ *
+ *             Barry was a man who loved his music.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+main(void)
+{
+       unsigned int j, i, k, numbits, data;
+
+       printf("/* sbc_crc.h - Automatically generated by sbc_crc.c. */\n\n");
+
+       /* The CRC-8 polynomial this uses is 0x11D */
+
+       numbits = 8;
+       for (k = 0; k < 2; k++) {
+               printf("static const uint8_t sbc_crc%u[256] = {\n\t", numbits);
+               for (i = 0; i < 256; i++) {
+                       data = i;
+
+                       for (j = 0; j < numbits; j++) {
+                               if (data & 0x80) {
+                                       data <<= 1;
+                                       data ^= 0x1d;
+                               } else
+                                       data <<= 1;
+                       }
+
+                       if (i % 8 == 0 && i != 0)
+                               printf("\n\t");
+
+                       printf("0x%02x, ", data & 0xff);
+               }
+               printf("\n};\n\n");
+
+               numbits /= 2;
+       }
+       return 0;
+}



Home | Main Index | Thread Index | Old Index