Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <time.h>
- #include "ppapi/c/pp_bool.h"
- #include "ppapi/c/pp_errors.h"
- #include "ppapi/c/pp_module.h"
- #include "ppapi/c/pp_instance.h"
- #include "ppapi/c/ppp.h"
- #include "ppapi/c/ppp_instance.h"
- typedef uint16_t vec_uint16_t __attribute__((vector_size(16)));
- #define LENGTH 64
- static int testfunc(uint8_t *a, uint8_t *b) {
- vec_uint16_t sumv = {0, 0, 0, 0, 0, 0, 0, 0};
- vec_uint16_t v1, v2, gt;
- for (int x=0; x<LENGTH; x+=8) {
- v1 = (vec_uint16_t){a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]};
- v2 = (vec_uint16_t){b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]};
- gt = v1>v2;
- sumv += (gt & (v1-v2)) + (~gt & (v2-v1));
- }
- return sumv[0]+sumv[1]+sumv[2]+sumv[3]+
- sumv[4]+sumv[5]+sumv[6]+sumv[7];
- }
- static PP_Bool Instance_DidCreate(PP_Instance instance,
- uint32_t argc,
- const char* argn[],
- const char* argv[]) {
- printf("Instance_DidCreate\n");
- srand(time(NULL));
- uint8_t a[LENGTH], b[LENGTH];
- for (int i=0; i<LENGTH; ++i) {
- a[i] = rand() % 256;
- b[i] = rand() % 256;
- printf("a[%i]=%i, b[%i]=%i\n", i, a[i], i, b[i]);
- }
- int sum = testfunc(a, b);
- printf("sum: %i\n", sum);
- return PP_TRUE;
- }
- static void Instance_DidDestroy(PP_Instance instance) {
- printf("Instance_DidDestroy\n");
- }
- static void Instance_DidChangeView(PP_Instance instance, PP_Resource view) {
- printf("Instance_DidChangeView\n");
- }
- static void Instance_DidChangeFocus(PP_Instance instance, PP_Bool has_focus) {
- printf("Instance_DidChangeFocus\n");
- }
- static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance, PP_Resource url_loader) {
- printf("Instance_HandleDocumentLoad\n");
- return PP_FALSE;
- }
- PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
- // Create structs for each PPP interface.
- // Assign the interface functions to the data fields.
- if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) {
- static PPP_Instance instance_interface = {
- &Instance_DidCreate,
- &Instance_DidDestroy,
- &Instance_DidChangeView,
- &Instance_DidChangeFocus,
- &Instance_HandleDocumentLoad
- };
- return &instance_interface;
- }
- // Return NULL for interfaces that you do not implement.
- return NULL;
- }
- // Define PPP_InitializeModule, the entry point of your module.
- // Retrieve the API for the browser-side (PPB) interfaces you will use.
- PP_EXPORT int32_t PPP_InitializeModule(PP_Module module, PPB_GetInterface get_browser_interface) {
- printf("PPP_InitializeModule\n");
- return PP_OK;
- }
- PP_EXPORT void PPP_ShutdownModule() {
- printf("PPP_ShutdownModule\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement