From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vladimir Zhbanov Newsgroups: gmane.lisp.guile.user Subject: Re: Lepton EDA 1.9.14 announce and misc questions Date: Wed, 21 Apr 2021 02:36:29 +0300 Message-ID: References: <510bfaf9-aa4f-50cd-deb3-7a15247a9bfa@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27315"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Apr 21 01:36:51 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYzvG-00070n-6z for guile-user@m.gmane-mx.org; Wed, 21 Apr 2021 01:36:50 +0200 Original-Received: from localhost ([::1]:48282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYzvF-0002I8-3G for guile-user@m.gmane-mx.org; Tue, 20 Apr 2021 19:36:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYzv3-0002Hf-68 for guile-user@gnu.org; Tue, 20 Apr 2021 19:36:37 -0400 Original-Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]:38409) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lYzv0-00061c-0I for guile-user@gnu.org; Tue, 20 Apr 2021 19:36:36 -0400 Original-Received: by mail-lj1-x232.google.com with SMTP id b38so4444627ljf.5 for ; Tue, 20 Apr 2021 16:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=AuDalQ0vJ/b7n2WZdjXLMXkZn1O7ZyTN+xMzlcmZRN8=; b=C3ZwUB4OTxfz9jXmpJuIqLAleXH/F531OhhTDpMpt1YLU7AbJZX86cIn/oXU86Hnhy cpwIcYcaCYHh0A+Zzxc5PMWA0JTQWZNqEXUt6fGiVgzJ3qYu4i+WYfsiCXQEX4ew2HfG 1zVQJiCG5kEpHzPNKMPV+at7qgJiCZbgTkWCFeWlK78Ud5SnOo3deEW6kbK8aoFQKVRD 03cpRQiQj7Nu0Zb7YGiTmpk4FjmHNSLzV09QI0P6x/jwYbUL2Y7pQNAxVS96U8gj3/S+ S1YeYf1oyANNvt0anwSFQ+nEs8mBQKGfcXQstcrVu7Kb2O7K2wIvFxpJ+cg6UaWSFjFN 60FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=AuDalQ0vJ/b7n2WZdjXLMXkZn1O7ZyTN+xMzlcmZRN8=; b=bP/pl0CRgd0Mn7kDrtuCy7aE8ZPm8uSPNcXebxWwmuO4v0Vn3zNZo3xwOJjo660Klz u6Ie9qA1KIvmq2SdJyvExVilm1wNvt5Ms4X3GibM2tbSGEpXF1gqQuK9s0tGAyQOPg3e oYnxnGm8TSmNcqPq1WcY/uGvcBFELZ8Jk6cJMMn3Rw4s8QQPu6ml7db6jLkVqSDTK+ZZ yXYojjdRP0+9jaoWx/9lsThCMUdqXn+fU6higanBHTRC1b6BILKttEXenMpsuECF5wZz bULoA5yBi9Xz+XbbWZwwrAl5hHHMnCpBlQEizm/9suvsoDCtys1+duP+qHiTr3Y4KDRn 6lIQ== X-Gm-Message-State: AOAM533jatzI11QMrqxe2WWhyw0MuxTCNk8mBNgBHvnVjpeHUe0qnjvk CONlG/tmEb00oFQfYyyeElgNBap994s= X-Google-Smtp-Source: ABdhPJwEyuwY+TGQvZUuU452dEFcbfIobGHKy4aYbOMEr/H0NTKKFbJYmCA1SaA9Cf6COEuJd8mfKg== X-Received: by 2002:a05:651c:3c1:: with SMTP id f1mr16671250ljp.507.1618961791866; Tue, 20 Apr 2021 16:36:31 -0700 (PDT) Original-Received: from lepton ([95.179.127.11]) by smtp.gmail.com with ESMTPSA id t63sm37012lff.92.2021.04.20.16.36.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 16:36:30 -0700 (PDT) X-Google-Original-From: Vladimir Zhbanov Original-Received: from vzh by lepton with local (Exim 4.94) (envelope-from ) id 1lYzuv-002pGy-Fz for guile-user@gnu.org; Wed, 21 Apr 2021 02:36:29 +0300 Mail-Followup-To: guile-user@gnu.org Content-Disposition: inline In-Reply-To: <510bfaf9-aa4f-50cd-deb3-7a15247a9bfa@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=vzhbanov@gmail.com; helo=mail-lj1-x232.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17428 Archived-At: Hi Matt, On Tue, Apr 20, 2021 at 06:46:27AM -0700, Matt Wette wrote: > > > On 4/20/21 5:47 AM, Matt Wette wrote: > > > > > > On 4/20/21 2:29 AM, Vladimir Zhbanov wrote: > > > Hi Guile users and devs, > > > > > > I'm the current maintainer of Lepton EDA suite, an about five year > > > old fork of geda-gaf with accent to moving more functionality to > > > Scheme code.  I'm not sure if it is acceptable to advertise it > > > here, please let me know if not.  I just know several Guix > > > packagers are reading this mailing list and would like to announce > > > a new version of Lepton, 1.9.14 has been released on April, 7: > > > > > > https://github.com/lepton-eda/lepton-eda/releases/tag/1.9.14-20210407 > > > > > > > > > > Sweet.  Thanks for posting this.   I will take a look at your problem. > > It'll require digging into the eda_..._dirs function. > > > > > > > The following should work as a complete program on a system w/ glib. > You need to first convert the result to a bytevector and then access the > elements (pointers) one at a time.  Note that we don't know how big the > array returned from the C function is.  I pick an oversized value of 100. > > (use-modules (system foreign)) > (use-modules (rnrs bytevectors)) > > (define glib (dynamic-link "libglib-2.0")) > > (define g-get-system-data-dirs >   (let ((f (pointer->procedure >         '* (dynamic-func "g_get_system_data_dirs" glib) (list))) >     (bv-pointer-ref (cond >              ((= (sizeof '*) 8) bytevector-u64-native-ref ) >              ((= (sizeof '*) 4) bytevector-u32-native-ref ) >              (else (error "hmmm")))) >     (BIG 100)) >     (lambda () >       (let* ((r (f)) >          (p (pointer->bytevector r (* BIG (sizeof '*))))) >         (let loop ((ix 0)) >           (let* ((ad (bv-pointer-ref p ix)) >              (sp (make-pointer ad))) >         (if (equal? %null-pointer sp) >             '() >             (cons (pointer->string sp) (loop (+ ix (sizeof '*))))))))))) > > (simple-format #t "~S" (g-get-system-data-dirs)) Thank you for your replies! Probably, I missed something here, so I'll try to elaborate a bit on my initial question. The function eda_get_system_data_dirs() mentioned in my first message has the same type, is defined the same way using dynamic-func though in liblepton instead of glib, and works on mostly the same array as glib's g_get_system_data_dirs(). The function I've shown works well and outputs the same results as yours. It simply uses a bit more upper level interface, IIUC. So the first question is: I wonder, if using bytevectors directly adds something here? Another issue is a little more confusing for me. I read in several places that even on the same system different compilators, say gcc and g++, may use different alignment even for basic C types like, say, double. What will they do on different platforms then? May it be that (alignof '*) will be twice greater than (sizeof '*)? In such a case using multiplied sizeof of pointer for searching the location of a pointer in memory would be just dangerous. I used sizeof in the first version of my code but started to doubt if it is correct and how portable it is. Thanks, Vladimir