Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 Nov 2017, 13:54
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Puppy In-House Development
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 26 of 27 [396 Posts]   Goto page: Previous 1, 2, 3, ..., 24, 25, 26, 27 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4756
Location: Kingwood, TX

PostPosted: Tue 02 Dec 2014, 19:27    Post subject:  

Ibidem wrote:

Did some poking at this (or rather the other version of this), and it works...except it stops halfway through.
You need to multiply (len*channels) by 2, since a short is 2 bytes.
(Thinking about a "multimedia edition" of toybox: include mix, wavplay, and oggplay.)

The standalone version is more up to date and is here:
https://github.com/technosaurus/PDVorbis/blob/master/oggplay2.c

I started using google's DNS servers lately because my ISP (a major cable company) has really slow and sometimes incorrect responses. This reminded me of what a PITA it is to simply translate a host name into an IP address for a wget-like tool, so I wrote a simple host->IP function
http://murga-linux.com/puppy/viewtopic.php?p=810724#810724

Switching to this drastically shrunk the size of my static build and the query time went from 500ms to about 20ms using google dns, but then I realized that it bypasses /etc/hosts ... kind of bad but useful for making a local caching CDN instead of the hacky version I did here:
http://www.murga-linux.com/puppy/viewtopic.php?t=82639

But this got me wondering how DNS caching works in Linux, but it turns out there isn't any by default. So now I am wondering about making one that can be used without a daemon process (those exist, but none are exactly suckless) Here is my outline:


* cached addresses are all stored in a common directory using the filesystem as a database
* blacklisting is done by making a hard link to a '0' file with "\0\0\0\0" stored as the ip address
* each hostname is first checked to see if there is a matching file name in the directory
* if the hostname exists, the ip address is read and returned,
* otherwise a DNS query is performed, IPs stored and returned

This also makes it straight forward to use groups for controlling access to sites with chgrp to make it {kid,workplace}-safe

To allow local CDN-like caching for all browsers, downloaders etc... just prepend the IP address list with 0x7F000001 (127.0.0.1) such that a local server can check its on disk cache, then use the second IP address to fetch it if not found ... maybe using the file's time stamp as the expiry time.

_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
linuxcbon

Joined: 09 Aug 2007
Posts: 1165

PostPosted: Mon 08 Dec 2014, 04:30    Post subject:  

- "searching for the home partition" : failure
Is it possible to make it work from a subdirectory or from a non-ext partition ? I don't know what the problem is.
- xinit doesn't work with a recent radeon video card.
Is it possible to make it work ?

Last edited by linuxcbon on Mon 08 Dec 2014, 06:48; edited 1 time in total
Back to top
View user's profile Send private message 
linuxcbon

Joined: 09 Aug 2007
Posts: 1165

PostPosted: Mon 08 Dec 2014, 04:30    Post subject:  

---- dual post --- to be removed
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 773

PostPosted: Sun 21 Dec 2014, 13:32    Post subject:  

Ibidem wrote:
technosaurus wrote:

if (ioctl(pcm, SNDCTL_DSP_CHANNELS, &channels) < 0)
write2("cannot set channels");
if (ioctl(pcm, SNDCTL_DSP_SPEED, &sample_rate) < 0)
write2("cannot set sample rate");
write(pcm,decoded,len*channels);


On error this looks like it will play some gawd awful noise. It reports the error onto stderr but doesn't leave nor does it do some sort of work-around for the failure.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4756
Location: Kingwood, TX

PostPosted: Sun 21 Dec 2014, 20:11    Post subject:  

Moose On The Loose wrote:


On error this looks like it will play some gawd awful noise. It reports the error onto stderr but doesn't leave nor does it do some sort of work-around for the failure.
Should probably perror_exit

Code:
void perror_exit(char *msg){
  write(2,msg,strlen(msg));
  exit(errno);
}

_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
slenkar

Joined: 10 Jul 2009
Posts: 228

PostPosted: Wed 11 Mar 2015, 07:14    Post subject:  

can you get skype for RLSD
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4756
Location: Kingwood, TX

PostPosted: Fri 08 May 2015, 17:10    Post subject:  

another code snippet for testing
simple command line or X11 image viewer using stb_image and netsurf's framebuffer backend libnsfb

It is by no means a full fledged image viewer, just a hacky starting point for one
Code:
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

#include "libnsfb.h"
#include "libnsfb_event.h"

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

int main(int argc, char **argv)
{
    nsfb_t *nsfb;
    nsfb_event_t event;
    unsigned char *obuf, *fbptr;
    int ocols, orows, fbstride=4, ch = 4;
    if (argc<2) return 1;

    obuf = stbi_load(argv[1], &ocols, &orows, &ch, 4);

    nsfb = nsfb_new((getenv("DISPLAY"))?NSFB_SURFACE_X:NSFB_SURFACE_LINUX);
    if (nsfb == NULL) {
        fwrite("can't allocate nsfb surface\n",1,32,stderr);
        return 2;
    }
    nsfb_set_geometry(nsfb, ocols, orows,NSFB_FMT_ARGB8888);
    if (nsfb_init(nsfb) == -1) {
        fwrite("can't initialise nsfb surface\n",1,30,stderr);
        nsfb_free(nsfb);
        return 3;
    }
    nsfb_get_buffer(nsfb, &fbptr, &fbstride);
    nsfb_bbox_t box = { .x0=0, .y0=0, .x1=ocols, .y1=orows };
   int i=0;
    while(i < (ocols * orows * 4)){
      *fbptr++=obuf[i+2];
      *fbptr++=obuf[i+1];
      *fbptr++=obuf[i];
      *fbptr++=0xff;
      i+=4;
   }
    nsfb_update(nsfb, &box);

    /* wait for quit event or timeout */
    while (1) {
   if (nsfb_event(nsfb, &event, 1000)  == false) {
       break;
   }
   if (event.type == NSFB_EVENT_CONTROL) {
       if (event.value.controlcode == NSFB_CONTROL_TIMEOUT) {
      /* timeout */
       } else if (event.value.controlcode == NSFB_CONTROL_QUIT) {
      break;
       }
   }
    }

    nsfb_free(nsfb);

    return 0;
}

_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4756
Location: Kingwood, TX

PostPosted: Fri 08 May 2015, 17:12    Post subject:  

and another for svg images using svgtiny ... TODO combine them

Code:
/*
 * This file is part of Libsvgtiny
 * Licensed under the MIT License,
 *                http://opensource.org/licenses/mit-license.php
 * Copyright 2008 James Bursa <james@semichrome.net>
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdlib.h>
#include "libnsfb.h"
#include "libnsfb_plot.h"
#include "libnsfb_event.h"
#include <svgtiny.h>



static int setup_fb(void);

int main(int argc, char *argv[])
{
    nsfb_t *nsfb;
    nsfb_bbox_t screen_box;
    uint8_t *fbptr;
    int fbstride;
    nsfb_event_t event;
    FILE *fd;
    float scale = 1.0;
    struct stat sb;
    char *buffer;
    size_t size;
    size_t n;
    struct svgtiny_diagram *diagram;
    svgtiny_code code;

    if (argc != 2 && argc != 3) {
        fprintf(stderr, "Usage: %s FILE [SCALE]\n", argv[0]);
        return 1;
    }

    /* load file into memory buffer */
    fd = fopen(argv[1], "rb");
    if (!fd) {
        perror(argv[1]);
        return 1;
    }

    if (stat(argv[1], &sb)) {
        perror(argv[1]);
        return 1;
    }
    size = sb.st_size;

    buffer = malloc(size);
    if (!buffer) {
        fprintf(stderr, "Unable to allocate %lld bytes\n",
                (long long) size);
        return 1;
    }

    n = fread(buffer, 1, size, fd);
    if (n != size) {
        perror(argv[1]);
        return 1;
    }

    fclose(fd);

    /* read scale argument */
    if (argc == 3) {
        scale = atof(argv[2]);
        if (scale == 0)
            scale = 1.0;
    }

    /* create svgtiny object */
    diagram = svgtiny_create();
    if (!diagram) {
        fprintf(stderr, "svgtiny_create failed\n");
        return 1;
    }

    /* parse */
    code = svgtiny_parse(diagram, buffer, size, argv[1], 1000, 1000);
    if (code != svgtiny_OK) {
        fprintf(stderr, "svgtiny_parse failed: ");
        switch (code) {
        case svgtiny_OUT_OF_MEMORY:
            fprintf(stderr, "svgtiny_OUT_OF_MEMORY");
            break;
        case svgtiny_LIBDOM_ERROR:
            fprintf(stderr, "svgtiny_LIBDOM_ERROR");
            break;
        case svgtiny_NOT_SVG:
            fprintf(stderr, "svgtiny_NOT_SVG");
            break;
        case svgtiny_SVG_ERROR:
            fprintf(stderr, "svgtiny_SVG_ERROR: line %i: %s",
                    diagram->error_line,
                    diagram->error_message);
            break;
        default:
            fprintf(stderr, "unknown svgtiny_code %i", code);
            break;
        }
        fprintf(stderr, "\n");
    }

    free(buffer);

    nsfb = nsfb_new((getenv("DISPLAY"))?NSFB_SURFACE_X:NSFB_SURFACE_LINUX);
    if (nsfb == NULL) {
        fprintf(stderr, "Unable to initialise nsfb with x frontend\n");
        return 1;
    }

    if (nsfb_init(nsfb) == -1) {
        fprintf(stderr, "Unable to initialise nsfb frontend\n");
        return 2;
    }

    /* get the geometry of the whole screen */
    screen_box.x0 = screen_box.y0 = 0;
    nsfb_get_geometry(nsfb, &screen_box.x1, &screen_box.y1, NULL);

    nsfb_get_buffer(nsfb, &fbptr, &fbstride);

    /* claim the whole screen for update */
    nsfb_claim(nsfb, &screen_box);

    nsfb_plot_clg(nsfb, 0xffffffff);

    for (unsigned int i = 0; i != diagram->shape_count; i++) {
        nsfb_plot_pen_t pen;
        pen.stroke_colour = svgtiny_RED(diagram->shape[i].stroke) |
                            svgtiny_GREEN(diagram->shape[i].stroke) << 8|
                            svgtiny_BLUE(diagram->shape[i].stroke) << 16;
        pen.fill_colour = svgtiny_RED(diagram->shape[i].fill) |
                            svgtiny_GREEN(diagram->shape[i].fill) << 8|
                            svgtiny_BLUE(diagram->shape[i].fill) << 16;

        if (diagram->shape[i].fill == svgtiny_TRANSPARENT)
            pen.fill_type = NFSB_PLOT_OPTYPE_NONE;
        else
            pen.fill_type = NFSB_PLOT_OPTYPE_SOLID;

        if (diagram->shape[i].stroke == svgtiny_TRANSPARENT)
            pen.stroke_type = NFSB_PLOT_OPTYPE_NONE;
        else
            pen.stroke_type = NFSB_PLOT_OPTYPE_SOLID;

        pen.stroke_width = scale * diagram->shape[i].stroke_width;

        if (diagram->shape[i].path) {
            nsfb_plot_pathop_t *fb_path;
            int fb_path_c;
            unsigned int j;
            fb_path = malloc(diagram->shape[i].path_length * 3 * sizeof(nsfb_plot_pathop_t));
            fb_path_c = 0;

            for (j = 0;
                 j != diagram->shape[i].path_length; ) {
                switch ((int) diagram->shape[i].path[j]) {
                case svgtiny_PATH_MOVE:
                    fb_path[fb_path_c].operation = NFSB_PLOT_PATHOP_MOVE;
                    fb_path[fb_path_c].point.x = scale * diagram->shape[i].path[j + 1];
                    fb_path[fb_path_c].point.y = scale * diagram->shape[i].path[j + 2];
                    fb_path_c++;
                    j += 3;
                    break;

                case svgtiny_PATH_CLOSE:   
                    fb_path[fb_path_c].operation = NFSB_PLOT_PATHOP_LINE;
                    fb_path[fb_path_c].point.x = fb_path[0].point.x;
                    fb_path[fb_path_c].point.y = fb_path[0].point.y;
                    fb_path_c++;
                    j += 1;
                    break;

                case svgtiny_PATH_LINE:
                    fb_path[fb_path_c].operation = NFSB_PLOT_PATHOP_LINE;
                    fb_path[fb_path_c].point.x = scale * diagram->shape[i].path[j + 1];
                    fb_path[fb_path_c].point.y = scale * diagram->shape[i].path[j + 2];
                    fb_path_c++;

                    j += 3;
                    break;

                case svgtiny_PATH_BEZIER:
                    fb_path[fb_path_c].operation = NFSB_PLOT_PATHOP_MOVE;
                    fb_path[fb_path_c].point.x = scale * diagram->shape[i].path[j + 1];
                    fb_path[fb_path_c].point.y = scale * diagram->shape[i].path[j + 2];
                    fb_path_c++;
                    fb_path[fb_path_c].operation = NFSB_PLOT_PATHOP_MOVE;
                    fb_path[fb_path_c].point.x = scale * diagram->shape[i].path[j + 3];
                    fb_path[fb_path_c].point.y = scale * diagram->shape[i].path[j + 4];
                    fb_path_c++;
                    fb_path[fb_path_c].operation = NFSB_PLOT_PATHOP_CUBIC;
                    fb_path[fb_path_c].point.x = scale * diagram->shape[i].path[j + 5];
                    fb_path[fb_path_c].point.y = scale * diagram->shape[i].path[j + 6];
                    fb_path_c++;

                    j += 7;
                    break;

                default:
                    printf("error ");
                    j += 1;
                }
            }

            nsfb_plot_path(nsfb, fb_path_c, fb_path, &pen);
        } else if (diagram->shape[i].text) {
            /* printf("text %g %g '%s' ",
               scale * diagram->shape[i].text_x,
               scale * diagram->shape[i].text_y,
               diagram->shape[i].text);*/
        }
    }

    svgtiny_free(diagram);

    nsfb_update(nsfb, &screen_box);
   
    while (event.type != NSFB_EVENT_CONTROL)
        nsfb_event(nsfb, &event, -1);

    return 0;
}

static int setup_fb(void)
{


    return 0;
}

/*

cc -g -std=c99 -D_BSD_SOURCE -I/home/vince/netsurf/libnsfb/include/ -I/home/vince/netsurf/libnsfb/src -I/usr/local/include -I/usr/include/libxml2 -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Werror -pedantic -Wno-overlength-strings   -DNDEBUG -O2 -DBUILD_TARGET_Linux -DBUILD_HOST_Linux -o build-Linux-Linux-release-lib-static/test_svgtiny.o -c test/svgtiny.c

cc -o build-Linux-Linux-release-lib-static/test_svgtiny build-Linux-Linux-release-lib-static/test_svgtiny.o -Wl,--whole-archive -lnsfb -Wl,--no-whole-archive -lSDL -Lbuild-Linux-Linux-release-lib-static/ -lnsfb -lsvgtiny -lxml2

 */

_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4756
Location: Kingwood, TX

PostPosted: Fri 15 May 2015, 22:47    Post subject:  

I just posted a tiny (tiny != efficient) mp3 player at http://murga-linux.com/puppy/viewtopic.php?t=59417 ... still needs a lot of optimization, but a good starting point
_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4756
Location: Kingwood, TX

PostPosted: Wed 20 May 2015, 02:20    Post subject:  

here is a work in progress of the alternative to package management for binary and libraries (regular files are still a mystery ... possibly handle them using inotify and locks on null files)

first we need a downloader, we'll call it binget
Code:
#!/bin/sh
REPO=ftp://example.com/rootdir
case "$1" in
*/lib/*)wget -q -O "$1" "$REPO$1";; #library
*)wget -q -O "/bin/$0" "$REPO/bin/$0";; #binary
esac

This doubles as the hardlink for any binaries we have in the repo (note the $0)
cd /bin
ln binget clang

Then we need something for libraries
Code:
#define _GNU_SOURCE
#include <dlfcn.h> //dladdr
#include <string.h> //strcat

__attribute__((constructor))
void on_load(void) {
  char cmd[256] = "binget ";
  Dl_info dl_info;
  dladdr((void *)on_load, &dl_info);
  strncat(cmd,dl_info.dli_fname,255-strlen(cmd));
  system(cmd);
  dlopen(dl_info.dli_fname,RTLD_GLOBAL|RTLD_NOW);
}

compile with:
gcc -shared -Wl,-soname,libhelper.so.1 -o libhelper.so.1 libhelper.c
cd /lib
ln libhelper.so.1 libLLVM-3.4.so.1

this will load, run on_load (before any symbols get resolved), figure out how it was called (as /lib/libLLVM-3.4.so.1) via dladdr and replace itself with the one it was called as (using binget) then reload the replacement via dlopen and load all the symbols (via RTLD_GLOBAL|RTLD_NOW)

_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4756
Location: Kingwood, TX

PostPosted: Sun 16 Aug 2015, 04:17    Post subject:  

64 bit CPUs have been around for well over a decade now and it's tough to find a used PC that isn't 64 bit.

Puppy has long catered to these older systems, but added support for things like PAE for newer systems. One of the biggest reasons we still use x86 is the extra bloat added for x86_64 just for pointers and long. Since Linux3.4 and gcc 4.7 (and new versions of clang) there is a way to get the faster instructions and smaller function call overhead of x86_64 with 32 bit pointers and long called x32.

I think this is something we should consider. Any thoughts against it?

_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
linuxcbon

Joined: 09 Aug 2007
Posts: 1165

PostPosted: Sun 16 Aug 2015, 18:42    Post subject:  

technosaurus wrote:
64 bit CPUs have been around for well over a decade now and it's tough to find a used PC that isn't 64 bit.
Puppy has long catered to these older systems, but added support for things like PAE for newer systems. One of the biggest reasons we still use x86 is the extra bloat added for x86_64 just for pointers and long. Since Linux3.4 and gcc 4.7 (and new versions of clang) there is a way to get the faster instructions and smaller function call overhead of x86_64 with 32 bit pointers and long called x32.
I think this is something we should consider. Any thoughts against it?

No. (this is my opinion following) Puppy was compiled for x86 to support old computers, that's all. Today, puppy cannot be x86_64 only, since those old 32 bit computers are still used and around (pentium, athlon, k5, k6, cyrix, via, etc).
As for "puppy in-house" I don't see any development anymore, it looks like a dead project, you should better use your energy improving the existing quirky april/appril. Wink
Back to top
View user's profile Send private message 
Iguleder


Joined: 11 Aug 2009
Posts: 2031
Location: Israel, somewhere in the beautiful desert

PostPosted: Mon 17 Aug 2015, 16:18    Post subject:  

I'm not convinced. x32 may improve performance only in some cases and creates compatibility issues (since you can't mix x32 binaries with x86_64 ones).
_________________
My homepage
My GitHub profile
Back to top
View user's profile Send private message Visit poster's website 
darry1966


Joined: 26 Feb 2012
Posts: 898

PostPosted: Thu 24 Sep 2015, 18:33    Post subject:  

Qoute"As for "puppy in-house" I don't see any development anymore, it looks like a dead project, you should better use your energy improving the existing quirky april/appril."

Sigh yep. Though other distros like LinuxBBQ can do the same job with less ram.
Back to top
View user's profile Send private message 
Ibidem

Joined: 25 May 2010
Posts: 553
Location: State of Jefferson

PostPosted: Thu 01 Oct 2015, 01:38    Post subject:  

technosaurus wrote:
64 bit CPUs have been around for well over a decade now and it's tough to find a used PC that isn't 64 bit.

Puppy has long catered to these older systems, but added support for things like PAE for newer systems. One of the biggest reasons we still use x86 is the extra bloat added for x86_64 just for pointers and long. Since Linux3.4 and gcc 4.7 (and new versions of clang) there is a way to get the faster instructions and smaller function call overhead of x86_64 with 32 bit pointers and long called x32.

I think this is something we should consider. Any thoughts against it?


I've got a 2009-vintage Acer Aspire One netbook that's in great shape.
Has an Atom N270 processor, which was one of Intel's last semi-'mainstream' 32-bit singlecore processors.

The Quark (Intel's licenseable 'embedded' CPU) is rather specialty; I don't expect it to be a concern for most. Pretty much Galileo and Edison boards are the main use.
But IIRC, it's Pentium (not mmx) ISA, usually single-core, no speedstep, ~400 MHz.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 26 of 27 [396 Posts]   Goto page: Previous 1, 2, 3, ..., 24, 25, 26, 27 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0910s ][ Queries: 12 (0.0161s) ][ GZIP on ]